create-quiver 0.15.4 → 0.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/pull_request_template.md +17 -0
- package/.github/workflows/ci.yml +76 -0
- package/.markdown-link-check.json +15 -0
- package/.markdownlint.json +11 -0
- package/ARCHITECTURE.md +133 -0
- package/CHANGELOG.md +16 -0
- package/CONTRIBUTING.md +174 -9
- package/README.md +17 -2
- package/README_FOR_AI.md +4 -1
- package/ROADMAP.md +4 -0
- package/SECURITY.md +9 -2
- package/docs/AI_CONTEXT.md.es.template +3 -1
- package/docs/AI_CONTEXT.md.template +3 -1
- package/docs/CLI_UX_GUIDE.md +20 -1
- package/docs/COMMANDS.md.template +20 -6
- package/docs/GITFLOW_PR_GUIDE.md +73 -11
- package/docs/GITFLOW_PR_GUIDE.md.es.template +61 -2
- package/docs/GITFLOW_PR_GUIDE.md.template +72 -10
- package/docs/INDEX.md +6 -1
- package/docs/QUICK.md.template +2 -1
- package/docs/STANDARD.md.template +2 -1
- package/docs/WORKFLOW.md.es.template +3 -1
- package/docs/WORKFLOW.md.template +6 -4
- package/docs/getting-started/installation.md +7 -0
- package/docs/reference/commands.md +138 -6
- package/docs/reference/slice-schema.md +37 -0
- package/docs/schema/slice.schema.json +221 -0
- package/docs/specs/01-spec/01-slice/01-slice.json +36 -0
- package/docs/specs/01-spec/01-slice/01-slice.md +106 -0
- package/docs/specs/01-spec/01-slice/CLOSURE_BRIEF.md +80 -0
- package/docs/specs/01-spec/01-slice/EXECUTION_BRIEF.md +39 -0
- package/docs/specs/01-spec/02-slice/02-slice.json +36 -0
- package/docs/specs/01-spec/02-slice/02-slice.md +108 -0
- package/docs/specs/01-spec/02-slice/CLOSURE_BRIEF.md +88 -0
- package/docs/specs/01-spec/02-slice/EXECUTION_BRIEF.md +40 -0
- package/docs/specs/01-spec/03-slice/03-slice.json +36 -0
- package/docs/specs/01-spec/03-slice/03-slice.md +103 -0
- package/docs/specs/01-spec/03-slice/CLOSURE_BRIEF.md +54 -0
- package/docs/specs/01-spec/03-slice/EXECUTION_BRIEF.md +39 -0
- package/docs/specs/01-spec/04-slice/04-slice.json +36 -0
- package/docs/specs/01-spec/04-slice/04-slice.md +107 -0
- package/docs/specs/01-spec/04-slice/CLOSURE_BRIEF.md +46 -0
- package/docs/specs/01-spec/04-slice/EXECUTION_BRIEF.md +39 -0
- package/docs/specs/01-spec/05-slice/05-slice.json +36 -0
- package/docs/specs/01-spec/05-slice/05-slice.md +106 -0
- package/docs/specs/01-spec/05-slice/CLOSURE_BRIEF.md +84 -0
- package/docs/specs/01-spec/05-slice/EXECUTION_BRIEF.md +109 -0
- package/docs/specs/01-spec/06-slice/06-slice.json +36 -0
- package/docs/specs/01-spec/06-slice/06-slice.md +107 -0
- package/docs/specs/01-spec/06-slice/CLOSURE_BRIEF.md +67 -0
- package/docs/specs/01-spec/06-slice/EXECUTION_BRIEF.md +39 -0
- package/docs/specs/01-spec/07-slice/07-slice.json +36 -0
- package/docs/specs/01-spec/07-slice/07-slice.md +105 -0
- package/docs/specs/01-spec/07-slice/CLOSURE_BRIEF.md +71 -0
- package/docs/specs/01-spec/07-slice/EXECUTION_BRIEF.md +39 -0
- package/docs/specs/01-spec/08-slice/08-slice.json +36 -0
- package/docs/specs/01-spec/08-slice/08-slice.md +105 -0
- package/docs/specs/01-spec/08-slice/CLOSURE_BRIEF.md +114 -0
- package/docs/specs/01-spec/08-slice/EXECUTION_BRIEF.md +39 -0
- package/docs/specs/01-spec/CLOSURE_BRIEF.md +87 -0
- package/docs/specs/01-spec/spec.md +197 -0
- package/docs/workflows/full-ai-spec-to-pr.md +46 -3
- package/i18n/es/docs/GITFLOW_PR_GUIDE.md.template +38 -1
- package/package.json +27 -1
- package/scripts/package-quiver.sh +82 -2
- package/scripts/release-quiver.sh +14 -3
- package/specs/[project-name]/slices/pr.md.template +19 -0
- package/specs/quiver-v43-cli-i18n-audit-release-readiness/command-language-mode-matrix.json +122 -1
- package/specs/quiver-v46-deep-project-analysis/EVIDENCE_REPORT.md +94 -0
- package/specs/quiver-v46-deep-project-analysis/EXECUTION_PLAN.md +26 -0
- package/specs/quiver-v46-deep-project-analysis/SPEC.md +157 -0
- package/specs/quiver-v46-deep-project-analysis/STATUS.md +26 -0
- package/specs/quiver-v46-deep-project-analysis/pr.md +131 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-00-analysis-contract-foundation/CLOSURE_BRIEF.md +14 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-00-analysis-contract-foundation/EXECUTION_BRIEF.md +41 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-00-analysis-contract-foundation/slice.json +61 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-01-stack-agnostic-discovery-sampling/CLOSURE_BRIEF.md +22 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-01-stack-agnostic-discovery-sampling/EXECUTION_BRIEF.md +33 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-01-stack-agnostic-discovery-sampling/slice.json +80 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-02-provider-analysis-json-contract/CLOSURE_BRIEF.md +21 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-02-provider-analysis-json-contract/EXECUTION_BRIEF.md +34 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-02-provider-analysis-json-contract/slice.json +79 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-03-doc-proposal-review-safe-writes/CLOSURE_BRIEF.md +19 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-03-doc-proposal-review-safe-writes/EXECUTION_BRIEF.md +33 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-03-doc-proposal-review-safe-writes/slice.json +79 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-04-validation-docs-release-readiness/CLOSURE_BRIEF.md +20 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-04-validation-docs-release-readiness/EXECUTION_BRIEF.md +32 -0
- package/specs/quiver-v46-deep-project-analysis/slices/slice-04-validation-docs-release-readiness/slice.json +85 -0
- package/specs/quiver-v50-audit-trust-foundation/EVIDENCE_REPORT.md +151 -0
- package/specs/quiver-v50-audit-trust-foundation/EXECUTION_PLAN.md +34 -0
- package/specs/quiver-v50-audit-trust-foundation/SPEC.md +113 -0
- package/specs/quiver-v50-audit-trust-foundation/STATUS.md +26 -0
- package/specs/quiver-v50-audit-trust-foundation/pr.md +120 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-00-audit-baseline-and-resolved-findings/CLOSURE_BRIEF.md +20 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-00-audit-baseline-and-resolved-findings/EXECUTION_BRIEF.md +58 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-00-audit-baseline-and-resolved-findings/slice.json +57 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-01-runtime-minimum-and-package-metadata/CLOSURE_BRIEF.md +24 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-01-runtime-minimum-and-package-metadata/EXECUTION_BRIEF.md +67 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-01-runtime-minimum-and-package-metadata/slice.json +71 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-02-migrate-write-safety-contract/CLOSURE_BRIEF.md +24 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-02-migrate-write-safety-contract/EXECUTION_BRIEF.md +71 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-02-migrate-write-safety-contract/slice.json +81 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-03-security-reporting-channel/CLOSURE_BRIEF.md +22 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-03-security-reporting-channel/EXECUTION_BRIEF.md +57 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-03-security-reporting-channel/slice.json +56 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-04-user-facing-i18n-error-coverage/CLOSURE_BRIEF.md +23 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-04-user-facing-i18n-error-coverage/EXECUTION_BRIEF.md +68 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-04-user-facing-i18n-error-coverage/slice.json +84 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-05-init-analyze-progress-and-summaries/CLOSURE_BRIEF.md +25 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-05-init-analyze-progress-and-summaries/EXECUTION_BRIEF.md +73 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-05-init-analyze-progress-and-summaries/slice.json +72 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-06-contributor-and-architecture-docs/CLOSURE_BRIEF.md +22 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-06-contributor-and-architecture-docs/EXECUTION_BRIEF.md +66 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-06-contributor-and-architecture-docs/slice.json +74 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-07-ci-and-documentation-lint-baseline/CLOSURE_BRIEF.md +29 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-07-ci-and-documentation-lint-baseline/EXECUTION_BRIEF.md +74 -0
- package/specs/quiver-v50-audit-trust-foundation/slices/slice-07-ci-and-documentation-lint-baseline/slice.json +81 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/EVIDENCE_REPORT.md +145 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/EXECUTION_PLAN.md +32 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/SPEC.md +109 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/STATUS.md +25 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/pr.md +69 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-00-cli-contract-baseline/CLOSURE_BRIEF.md +20 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-00-cli-contract-baseline/EXECUTION_BRIEF.md +58 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-00-cli-contract-baseline/slice.json +56 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-01-flow-json-compatibility/CLOSURE_BRIEF.md +21 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-01-flow-json-compatibility/EXECUTION_BRIEF.md +61 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-01-flow-json-compatibility/slice.json +68 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-02-dashboard-section-validation-i18n/CLOSURE_BRIEF.md +25 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-02-dashboard-section-validation-i18n/EXECUTION_BRIEF.md +65 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-02-dashboard-section-validation-i18n/pr.md +134 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-02-dashboard-section-validation-i18n/slice.json +80 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-03-base-branch-resolution-policy/CLOSURE_BRIEF.md +31 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-03-base-branch-resolution-policy/EXECUTION_BRIEF.md +80 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-03-base-branch-resolution-policy/pr.md +159 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-03-base-branch-resolution-policy/slice.json +102 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-04-next-plan-graph-ux-edge-cases/CLOSURE_BRIEF.md +25 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-04-next-plan-graph-ux-edge-cases/EXECUTION_BRIEF.md +74 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-04-next-plan-graph-ux-edge-cases/pr.md +147 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-04-next-plan-graph-ux-edge-cases/slice.json +91 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-05-evidence-robustness-path-safety/CLOSURE_BRIEF.md +28 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-05-evidence-robustness-path-safety/EXECUTION_BRIEF.md +73 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-05-evidence-robustness-path-safety/pr.md +146 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-05-evidence-robustness-path-safety/slice.json +100 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-06-namespace-compatibility-windows-scripts/CLOSURE_BRIEF.md +36 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-06-namespace-compatibility-windows-scripts/EXECUTION_BRIEF.md +76 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-06-namespace-compatibility-windows-scripts/pr.md +155 -0
- package/specs/quiver-v51-cli-ergonomics-automation-contracts/slices/slice-06-namespace-compatibility-windows-scripts/slice.json +111 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/EVIDENCE_REPORT.md +95 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/EXECUTION_PLAN.md +31 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/SPEC.md +107 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/STATUS.md +22 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/pr.md +69 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-00-schema-docs-release-baseline/CLOSURE_BRIEF.md +21 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-00-schema-docs-release-baseline/EXECUTION_BRIEF.md +60 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-00-schema-docs-release-baseline/slice.json +62 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-01-json-schema-for-slice-json/CLOSURE_BRIEF.md +34 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-01-json-schema-for-slice-json/EXECUTION_BRIEF.md +71 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-01-json-schema-for-slice-json/pr.md +146 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-01-json-schema-for-slice-json/slice.json +106 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-02-generated-cli-reference/CLOSURE_BRIEF.md +33 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-02-generated-cli-reference/EXECUTION_BRIEF.md +67 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-02-generated-cli-reference/pr.md +144 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-02-generated-cli-reference/slice.json +86 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-03-changelog-package-release-smoke-hygiene/CLOSURE_BRIEF.md +38 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-03-changelog-package-release-smoke-hygiene/EXECUTION_BRIEF.md +75 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-03-changelog-package-release-smoke-hygiene/pr.md +159 -0
- package/specs/quiver-v52-schema-docs-release-hygiene/slices/slice-03-changelog-package-release-smoke-hygiene/slice.json +105 -0
- package/src/create-quiver/commands/ai.js +521 -0
- package/src/create-quiver/commands/changelog.js +93 -0
- package/src/create-quiver/commands/config.js +16 -5
- package/src/create-quiver/commands/evidence.js +33 -2
- package/src/create-quiver/commands/flow.js +1 -0
- package/src/create-quiver/commands/graph.js +8 -2
- package/src/create-quiver/commands/plan.js +6 -0
- package/src/create-quiver/commands/spec.js +28 -13
- package/src/create-quiver/index.js +408 -98
- package/src/create-quiver/lib/ai/analyze-project-discovery.js +387 -0
- package/src/create-quiver/lib/ai/analyze-project-docs.js +364 -0
- package/src/create-quiver/lib/ai/analyze-project-parser.js +277 -0
- package/src/create-quiver/lib/ai/analyze-project-prompts.js +214 -0
- package/src/create-quiver/lib/ai/analyze-project-review.js +99 -0
- package/src/create-quiver/lib/ai/analyze-project-sampling.js +402 -0
- package/src/create-quiver/lib/ai/analyze-project-schema.js +92 -0
- package/src/create-quiver/lib/ai/analyze-project-validation.js +309 -0
- package/src/create-quiver/lib/ai/artifacts.js +4 -1
- package/src/create-quiver/lib/ai/github.js +5 -2
- package/src/create-quiver/lib/ai/spec-templates.js +19 -0
- package/src/create-quiver/lib/cli/command-registry.js +72 -0
- package/src/create-quiver/lib/cli/parser.js +14 -0
- package/src/create-quiver/lib/evidence.js +161 -6
- package/src/create-quiver/lib/git.js +99 -0
- package/src/create-quiver/lib/i18n/messages/en.js +52 -7
- package/src/create-quiver/lib/i18n/messages/es.js +54 -9
- package/src/create-quiver/lib/init-docs.js +1 -1
- package/src/create-quiver/lib/init-layout.js +9 -8
- package/src/create-quiver/lib/lifecycle.js +24 -26
- package/src/create-quiver/lib/readiness.js +67 -56
- package/src/create-quiver/lib/spec-worktrees.js +16 -34
|
@@ -0,0 +1,387 @@
|
|
|
1
|
+
const fs = require('node:fs');
|
|
2
|
+
const path = require('node:path');
|
|
3
|
+
|
|
4
|
+
const { getContextPathExclusionReason } = require('./safety');
|
|
5
|
+
const { classifyProjectFile, summarizeByReason } = require('./analyze-project-sampling');
|
|
6
|
+
|
|
7
|
+
const BINARY_EXTENSIONS = new Set([
|
|
8
|
+
'.7z',
|
|
9
|
+
'.avif',
|
|
10
|
+
'.bmp',
|
|
11
|
+
'.class',
|
|
12
|
+
'.dll',
|
|
13
|
+
'.dmg',
|
|
14
|
+
'.doc',
|
|
15
|
+
'.docx',
|
|
16
|
+
'.eot',
|
|
17
|
+
'.exe',
|
|
18
|
+
'.gif',
|
|
19
|
+
'.gz',
|
|
20
|
+
'.ico',
|
|
21
|
+
'.jar',
|
|
22
|
+
'.jpeg',
|
|
23
|
+
'.jpg',
|
|
24
|
+
'.lockb',
|
|
25
|
+
'.mov',
|
|
26
|
+
'.mp3',
|
|
27
|
+
'.mp4',
|
|
28
|
+
'.otf',
|
|
29
|
+
'.pdf',
|
|
30
|
+
'.png',
|
|
31
|
+
'.so',
|
|
32
|
+
'.tar',
|
|
33
|
+
'.ttf',
|
|
34
|
+
'.wasm',
|
|
35
|
+
'.webm',
|
|
36
|
+
'.webp',
|
|
37
|
+
'.woff',
|
|
38
|
+
'.woff2',
|
|
39
|
+
'.zip',
|
|
40
|
+
]);
|
|
41
|
+
|
|
42
|
+
function toPosix(filePath) {
|
|
43
|
+
return String(filePath || '').replace(/\\/g, '/');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function relativePath(from, to) {
|
|
47
|
+
const relative = toPosix(path.relative(from, to));
|
|
48
|
+
return relative || '.';
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function isInside(parent, child) {
|
|
52
|
+
const relative = path.relative(parent, child);
|
|
53
|
+
return relative === '' || (!relative.startsWith('..') && !path.isAbsolute(relative));
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function safeReadJson(filePath) {
|
|
57
|
+
try {
|
|
58
|
+
return JSON.parse(fs.readFileSync(filePath, 'utf8'));
|
|
59
|
+
} catch (_) {
|
|
60
|
+
return null;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function detectPackageManager(repoRoot) {
|
|
65
|
+
const checks = [
|
|
66
|
+
['pnpm', 'pnpm-lock.yaml'],
|
|
67
|
+
['yarn', 'yarn.lock'],
|
|
68
|
+
['npm', 'package-lock.json'],
|
|
69
|
+
['bun', 'bun.lockb'],
|
|
70
|
+
];
|
|
71
|
+
for (const [manager, fileName] of checks) {
|
|
72
|
+
if (fs.existsSync(path.join(repoRoot, fileName))) {
|
|
73
|
+
return manager;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const pkg = safeReadJson(path.join(repoRoot, 'package.json'));
|
|
77
|
+
if (pkg && typeof pkg.packageManager === 'string') {
|
|
78
|
+
return pkg.packageManager.split('@')[0] || 'unknown';
|
|
79
|
+
}
|
|
80
|
+
return 'unknown';
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function readPackageJson(repoRoot, relativeDir = '.') {
|
|
84
|
+
const packagePath = path.join(repoRoot, relativeDir, 'package.json');
|
|
85
|
+
const pkg = fs.existsSync(packagePath) ? safeReadJson(packagePath) : null;
|
|
86
|
+
return pkg && typeof pkg === 'object' ? pkg : null;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
function expandWorkspacePattern(repoRoot, pattern) {
|
|
90
|
+
const normalized = toPosix(pattern).trim();
|
|
91
|
+
if (!normalized || normalized.startsWith('!')) {
|
|
92
|
+
return [];
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
const withoutRecursive = normalized.replace(/\/\*\*.*$/, '');
|
|
96
|
+
if (!withoutRecursive.includes('*')) {
|
|
97
|
+
const absolute = path.resolve(repoRoot, withoutRecursive);
|
|
98
|
+
return fs.existsSync(absolute) && fs.statSync(absolute).isDirectory() ? [relativePath(repoRoot, absolute)] : [];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const parts = withoutRecursive.split('/');
|
|
102
|
+
const starIndex = parts.indexOf('*');
|
|
103
|
+
if (starIndex === -1) {
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const baseRelative = parts.slice(0, starIndex).join('/') || '.';
|
|
108
|
+
const suffix = parts.slice(starIndex + 1);
|
|
109
|
+
const baseAbsolute = path.resolve(repoRoot, baseRelative);
|
|
110
|
+
if (!fs.existsSync(baseAbsolute) || !fs.statSync(baseAbsolute).isDirectory()) {
|
|
111
|
+
return [];
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const results = [];
|
|
115
|
+
for (const entry of fs.readdirSync(baseAbsolute, { withFileTypes: true })) {
|
|
116
|
+
if (!entry.isDirectory()) {
|
|
117
|
+
continue;
|
|
118
|
+
}
|
|
119
|
+
const workspaceAbsolute = path.join(baseAbsolute, entry.name, ...suffix);
|
|
120
|
+
if (fs.existsSync(workspaceAbsolute) && fs.statSync(workspaceAbsolute).isDirectory()) {
|
|
121
|
+
results.push(relativePath(repoRoot, workspaceAbsolute));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return results;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function readPnpmWorkspacePatterns(repoRoot) {
|
|
128
|
+
const filePath = path.join(repoRoot, 'pnpm-workspace.yaml');
|
|
129
|
+
if (!fs.existsSync(filePath)) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
const lines = fs.readFileSync(filePath, 'utf8').split(/\r?\n/);
|
|
133
|
+
return lines
|
|
134
|
+
.map((line) => line.trim().match(/^-\s+['"]?([^'"]+)['"]?$/))
|
|
135
|
+
.filter(Boolean)
|
|
136
|
+
.map((match) => match[1]);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function discoverWorkspaceRoots(repoRoot) {
|
|
140
|
+
const rootPackage = readPackageJson(repoRoot);
|
|
141
|
+
const patterns = [];
|
|
142
|
+
const sources = new Map();
|
|
143
|
+
|
|
144
|
+
if (rootPackage && Array.isArray(rootPackage.workspaces)) {
|
|
145
|
+
for (const pattern of rootPackage.workspaces) {
|
|
146
|
+
patterns.push(pattern);
|
|
147
|
+
sources.set(pattern, 'package.json#workspaces');
|
|
148
|
+
}
|
|
149
|
+
} else if (rootPackage && rootPackage.workspaces && Array.isArray(rootPackage.workspaces.packages)) {
|
|
150
|
+
for (const pattern of rootPackage.workspaces.packages) {
|
|
151
|
+
patterns.push(pattern);
|
|
152
|
+
sources.set(pattern, 'package.json#workspaces.packages');
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
for (const pattern of readPnpmWorkspacePatterns(repoRoot)) {
|
|
157
|
+
patterns.push(pattern);
|
|
158
|
+
sources.set(pattern, 'pnpm-workspace.yaml');
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
for (const conventional of ['apps/*', 'packages/*']) {
|
|
162
|
+
if (fs.existsSync(path.join(repoRoot, conventional.split('/')[0]))) {
|
|
163
|
+
patterns.push(conventional);
|
|
164
|
+
sources.set(conventional, 'convention');
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const rootsByPath = new Map();
|
|
169
|
+
rootsByPath.set('.', {
|
|
170
|
+
name: rootPackage?.name || path.basename(repoRoot),
|
|
171
|
+
path: '.',
|
|
172
|
+
source: 'repo-root',
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
for (const pattern of patterns) {
|
|
176
|
+
for (const relative of expandWorkspacePattern(repoRoot, pattern)) {
|
|
177
|
+
const pkg = readPackageJson(repoRoot, relative);
|
|
178
|
+
rootsByPath.set(relative, {
|
|
179
|
+
name: pkg?.name || path.basename(relative),
|
|
180
|
+
path: relative,
|
|
181
|
+
source: sources.get(pattern) || 'workspace-pattern',
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
return [...rootsByPath.values()].sort((a, b) => a.path.localeCompare(b.path));
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
function resolveAnalysisRoot(repoRoot, scope, workspaceRoots) {
|
|
190
|
+
if (!scope) {
|
|
191
|
+
return {
|
|
192
|
+
absolutePath: repoRoot,
|
|
193
|
+
relativePath: '.',
|
|
194
|
+
source: 'repo-root',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
const matchingWorkspace = workspaceRoots.find((workspace) => workspace.name === scope || workspace.path === scope);
|
|
199
|
+
if (matchingWorkspace) {
|
|
200
|
+
return {
|
|
201
|
+
absolutePath: path.resolve(repoRoot, matchingWorkspace.path),
|
|
202
|
+
relativePath: matchingWorkspace.path,
|
|
203
|
+
source: 'workspace-scope',
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
const absolutePath = path.resolve(repoRoot, scope);
|
|
208
|
+
if (!isInside(repoRoot, absolutePath)) {
|
|
209
|
+
throw new Error(`scope is outside the repository: ${scope}`);
|
|
210
|
+
}
|
|
211
|
+
if (!fs.existsSync(absolutePath) || !fs.statSync(absolutePath).isDirectory()) {
|
|
212
|
+
throw new Error(`scope directory does not exist: ${scope}`);
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return {
|
|
216
|
+
absolutePath,
|
|
217
|
+
relativePath: relativePath(repoRoot, absolutePath),
|
|
218
|
+
source: 'path-scope',
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
function isBinaryFile(filePath) {
|
|
223
|
+
const extension = path.extname(filePath).toLowerCase();
|
|
224
|
+
if (BINARY_EXTENSIONS.has(extension)) {
|
|
225
|
+
return true;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
let descriptor;
|
|
229
|
+
try {
|
|
230
|
+
descriptor = fs.openSync(filePath, 'r');
|
|
231
|
+
const buffer = Buffer.alloc(1024);
|
|
232
|
+
const bytesRead = fs.readSync(descriptor, buffer, 0, buffer.length, 0);
|
|
233
|
+
for (let index = 0; index < bytesRead; index += 1) {
|
|
234
|
+
if (buffer[index] === 0) {
|
|
235
|
+
return true;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
} catch (_) {
|
|
239
|
+
return true;
|
|
240
|
+
} finally {
|
|
241
|
+
if (typeof descriptor === 'number') {
|
|
242
|
+
fs.closeSync(descriptor);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
return false;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
function walkFiles(repoRoot, analysisRoot) {
|
|
250
|
+
const files = [];
|
|
251
|
+
const skipped = [];
|
|
252
|
+
const safetyExclusions = [];
|
|
253
|
+
|
|
254
|
+
function visit(currentPath) {
|
|
255
|
+
const entries = fs.readdirSync(currentPath, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
|
|
256
|
+
for (const entry of entries) {
|
|
257
|
+
const absolutePath = path.join(currentPath, entry.name);
|
|
258
|
+
const relative = relativePath(repoRoot, absolutePath);
|
|
259
|
+
const normalizedRelative = relative === '.' ? entry.name : relative;
|
|
260
|
+
|
|
261
|
+
if (entry.isSymbolicLink()) {
|
|
262
|
+
skipped.push({ path: toPosix(normalizedRelative), reason: 'symlink' });
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
const exclusionReason = getContextPathExclusionReason(normalizedRelative);
|
|
267
|
+
if (exclusionReason) {
|
|
268
|
+
safetyExclusions.push({ path: toPosix(normalizedRelative), reason: exclusionReason });
|
|
269
|
+
continue;
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (entry.isDirectory()) {
|
|
273
|
+
visit(absolutePath);
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
if (!entry.isFile()) {
|
|
278
|
+
skipped.push({ path: toPosix(normalizedRelative), reason: 'not-regular-file' });
|
|
279
|
+
continue;
|
|
280
|
+
}
|
|
281
|
+
|
|
282
|
+
const stat = fs.statSync(absolutePath);
|
|
283
|
+
if (isBinaryFile(absolutePath)) {
|
|
284
|
+
skipped.push({ path: toPosix(normalizedRelative), reason: 'binary-file' });
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
files.push({
|
|
289
|
+
path: toPosix(normalizedRelative),
|
|
290
|
+
bytes: stat.size,
|
|
291
|
+
});
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
visit(analysisRoot);
|
|
296
|
+
return { files, safetyExclusions, skipped };
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
function detectStack(repoRoot, files) {
|
|
300
|
+
const stack = new Set();
|
|
301
|
+
const configs = [];
|
|
302
|
+
const entrypoints = [];
|
|
303
|
+
const sourceRoots = new Set();
|
|
304
|
+
const packageJson = readPackageJson(repoRoot);
|
|
305
|
+
const dependencies = {
|
|
306
|
+
...(packageJson?.dependencies || {}),
|
|
307
|
+
...(packageJson?.devDependencies || {}),
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
for (const dependency of Object.keys(dependencies)) {
|
|
311
|
+
if (dependency === 'next') stack.add('nextjs');
|
|
312
|
+
if (dependency === 'react') stack.add('react');
|
|
313
|
+
if (dependency === 'vue') stack.add('vue');
|
|
314
|
+
if (dependency === 'svelte') stack.add('svelte');
|
|
315
|
+
if (dependency === '@nestjs/core') stack.add('nestjs');
|
|
316
|
+
if (dependency === 'express') stack.add('express');
|
|
317
|
+
if (dependency === 'fastify') stack.add('fastify');
|
|
318
|
+
if (dependency === 'prisma' || dependency === '@prisma/client') stack.add('prisma');
|
|
319
|
+
if (dependency === 'drizzle-orm') stack.add('drizzle');
|
|
320
|
+
if (dependency.includes('supabase')) stack.add('supabase');
|
|
321
|
+
if (dependency === 'typescript') stack.add('typescript');
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
for (const file of files) {
|
|
325
|
+
const classification = classifyProjectFile(file.path);
|
|
326
|
+
const firstSegment = file.path.split('/')[0];
|
|
327
|
+
if (classification.signals.includes('config')) {
|
|
328
|
+
configs.push(file.path);
|
|
329
|
+
}
|
|
330
|
+
if (classification.signals.includes('entrypoint')) {
|
|
331
|
+
entrypoints.push(file.path);
|
|
332
|
+
}
|
|
333
|
+
if (classification.signals.some((signal) => ['source', 'frontend', 'backend'].includes(signal))) {
|
|
334
|
+
sourceRoots.add(firstSegment);
|
|
335
|
+
}
|
|
336
|
+
|
|
337
|
+
const base = path.posix.basename(file.path);
|
|
338
|
+
if (base === 'pyproject.toml') stack.add('python');
|
|
339
|
+
if (base === 'pom.xml') stack.add('java');
|
|
340
|
+
if (base === 'Gemfile') stack.add('ruby');
|
|
341
|
+
if (base === 'go.mod') stack.add('go');
|
|
342
|
+
if (base === 'composer.json') stack.add('php');
|
|
343
|
+
if (base === 'pubspec.yaml') stack.add('dart');
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
return {
|
|
347
|
+
stack: [...stack].sort(),
|
|
348
|
+
configs: configs.sort(),
|
|
349
|
+
entrypoints: entrypoints.sort(),
|
|
350
|
+
source_roots: [...sourceRoots].sort(),
|
|
351
|
+
scripts: packageJson?.scripts || {},
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
|
|
355
|
+
function discoverProjectFiles(repoRoot, options = {}) {
|
|
356
|
+
const resolvedRepoRoot = path.resolve(repoRoot);
|
|
357
|
+
const workspaceRoots = discoverWorkspaceRoots(resolvedRepoRoot);
|
|
358
|
+
const analysisRoot = resolveAnalysisRoot(resolvedRepoRoot, options.scope, workspaceRoots);
|
|
359
|
+
const walked = walkFiles(resolvedRepoRoot, analysisRoot.absolutePath);
|
|
360
|
+
const packageJson = readPackageJson(resolvedRepoRoot);
|
|
361
|
+
|
|
362
|
+
return {
|
|
363
|
+
project: {
|
|
364
|
+
name: packageJson?.name || path.basename(resolvedRepoRoot),
|
|
365
|
+
root: resolvedRepoRoot,
|
|
366
|
+
package_manager: detectPackageManager(resolvedRepoRoot),
|
|
367
|
+
},
|
|
368
|
+
roots: {
|
|
369
|
+
repo_root: resolvedRepoRoot,
|
|
370
|
+
analysis_root: analysisRoot.relativePath,
|
|
371
|
+
analysis_root_source: analysisRoot.source,
|
|
372
|
+
workspaces: workspaceRoots,
|
|
373
|
+
},
|
|
374
|
+
files: walked.files,
|
|
375
|
+
skippedFiles: walked.skipped,
|
|
376
|
+
skippedSummary: summarizeByReason(walked.skipped),
|
|
377
|
+
safetyExclusions: walked.safetyExclusions,
|
|
378
|
+
safetySummary: summarizeByReason(walked.safetyExclusions),
|
|
379
|
+
detected: detectStack(resolvedRepoRoot, walked.files),
|
|
380
|
+
};
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
module.exports = {
|
|
384
|
+
discoverProjectFiles,
|
|
385
|
+
discoverWorkspaceRoots,
|
|
386
|
+
resolveAnalysisRoot,
|
|
387
|
+
};
|