@thebackstoryis/engineering-with-ai 0.2.9
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/Docs/README.md +50 -0
- package/Docs/adoption/consultancy-and-multi-project-rollout.md +135 -0
- package/Docs/adoption/non-technical-team-guide.md +126 -0
- package/Docs/archaeology-technology-and-hosting-discovery.md +212 -0
- package/Docs/blast-radius-and-impact-routing-guide.md +325 -0
- package/Docs/blueprints/internal-blueprint-catalogue.md +146 -0
- package/Docs/blueprints/maintaining-organisation-blueprints.md +154 -0
- package/Docs/blueprints/validation-and-troubleshooting.md +168 -0
- package/Docs/cli-reference.md +113 -0
- package/Docs/completed-phase-evidence-amendments.md +74 -0
- package/Docs/consultancy-network-rollout-control-plane-guide.md +202 -0
- package/Docs/context-aware-delivery-companion-guide.md +198 -0
- package/Docs/context-aware-delivery-companion-user-guide.md +184 -0
- package/Docs/context-management-and-token-efficiency.md +113 -0
- package/Docs/design-systems/design-system-implementation-guide.md +85 -0
- package/Docs/design-systems/design-system-pack-authoring-guide.md +95 -0
- package/Docs/design-systems/design-system-review-guide.md +51 -0
- package/Docs/design-systems/design-system-user-guide.md +96 -0
- package/Docs/design-systems/product-owner-guide.md +49 -0
- package/Docs/designing-organisation-blueprint-packs.md +384 -0
- package/Docs/developer-delivery-guide.md +224 -0
- package/Docs/error-reporting-guide.md +110 -0
- package/Docs/error-reporting-provider-guide.md +49 -0
- package/Docs/examples/error-report-adapter.md +70 -0
- package/Docs/examples/meeting-review.md +76 -0
- package/Docs/examples/minimal-design-system.md +67 -0
- package/Docs/examples/prototype-review-inputs.md +175 -0
- package/Docs/examples/reproducible-archaeology-depth-example.md +144 -0
- package/Docs/examples/test-scenario-input.md +68 -0
- package/Docs/examples/worked-examples.md +147 -0
- package/Docs/existing-project-onboarding-guide.md +214 -0
- package/Docs/explanation/core-concepts.md +26 -0
- package/Docs/explanation/delivery-workflow.md +48 -0
- package/Docs/governance/governance-team-guide.md +139 -0
- package/Docs/governed-starter-project-materialisation-guide.md +284 -0
- package/Docs/guide-catalogue.md +117 -0
- package/Docs/guided-discovery-facilitator-guide.md +172 -0
- package/Docs/guided-intent-workspace-guide.md +109 -0
- package/Docs/guided-phase-evidence-drafting-guide.md +119 -0
- package/Docs/human-approval-and-assurance-guide.md +146 -0
- package/Docs/knowledge-proposals-implementer-guide.md +106 -0
- package/Docs/knowledge-proposals-user-guide.md +247 -0
- package/Docs/maintainers/context-benchmarks.md +29 -0
- package/Docs/maintainers/contributing.md +58 -0
- package/Docs/maintainers/evidence-depth-acceptance.md +72 -0
- package/Docs/maintainers/verification-walkthroughs.md +104 -0
- package/Docs/meeting-evidence-implementer-guide.md +132 -0
- package/Docs/meeting-evidence-user-guide.md +200 -0
- package/Docs/operations/dashboard-and-delivery-state.md +153 -0
- package/Docs/operations/dashboard-configuration.md +87 -0
- package/Docs/operations/installation-updating-and-entitlements.md +135 -0
- package/Docs/operations/premium-personas-setup.md +76 -0
- package/Docs/operations/troubleshooting-and-recovery.md +205 -0
- package/Docs/organisation-rollout-guide.md +142 -0
- package/Docs/persona-entitlement-provider-guide.md +199 -0
- package/Docs/persona-guided-prototype-iteration.md +129 -0
- package/Docs/personas/organisation-specific-personas.md +103 -0
- package/Docs/personas/persona-authoring-cookbook.md +176 -0
- package/Docs/personas/persona-engagement-ui.md +133 -0
- package/Docs/personas/persona-governance.md +118 -0
- package/Docs/platform-export-analysis-guide.md +336 -0
- package/Docs/policies/governance-owner-guide.md +36 -0
- package/Docs/policies/implementation-guide.md +42 -0
- package/Docs/policies/organisation-policy-design-gates.md +58 -0
- package/Docs/policies/policy-pack-authoring-guide.md +108 -0
- package/Docs/policies/product-owner-guide.md +43 -0
- package/Docs/policies/technical-owner-guide.md +37 -0
- package/Docs/product-owner-guide.md +327 -0
- package/Docs/project-portfolio-orchestration-guide.md +199 -0
- package/Docs/quality/manual-qa-and-acceptance.md +162 -0
- package/Docs/quality/persona-driven-test-scenarios.md +172 -0
- package/Docs/quality/reproducible-archaeology-depth-review-checklist.md +89 -0
- package/Docs/reference/capabilities-and-project-layout.md +678 -0
- package/Docs/reference/cli-and-configuration.md +398 -0
- package/Docs/reference/contributions-api.md +23 -0
- package/Docs/reference/security-adapter-authoring.md +81 -0
- package/Docs/reference/starter-adapter-authoring.md +74 -0
- package/Docs/repository-source-map-guide.md +381 -0
- package/Docs/reproducible-archaeology-and-discovery-depth.md +292 -0
- package/Docs/screen-prototype-creation-guide.md +324 -0
- package/Docs/security-validation-guide.md +353 -0
- package/Docs/solution-readiness-review-guide.md +123 -0
- package/Docs/standards/project-standards-authoring.md +157 -0
- package/Docs/team-hub-guide.md +162 -0
- package/Docs/team-hub-resource-registry-guide.md +167 -0
- package/Docs/tutorials/first-delivery.md +83 -0
- package/Docs/tutorials/first-session.md +62 -0
- package/Docs/using-lifecycle-hooks.md +381 -0
- package/Docs/working-with-personas.md +274 -0
- package/LICENSE +165 -0
- package/README.md +96 -0
- package/agents-src/claude/ewai-security-reviewer.md +15 -0
- package/bin/ewai +5 -0
- package/config/archaeology-record-families.yaml +59 -0
- package/config/delivery-artifacts.yaml +121 -0
- package/config/delivery-stages.yaml +77 -0
- package/config/design-system.schema.json +46 -0
- package/config/error-reporting.schema.json +79 -0
- package/config/evidence-depth.schema.json +53 -0
- package/config/intent.schema.json +90 -0
- package/config/knowledge-proposals-proposal.schema.json +34 -0
- package/config/lifecycle-event.schema.json +68 -0
- package/config/lifecycle-handler.schema.json +45 -0
- package/config/lifecycle-hook-ack.schema.json +19 -0
- package/config/meeting-evidence-candidate.schema.json +102 -0
- package/config/organisation-policy.schema.json +137 -0
- package/config/pack.schema.json +250 -0
- package/config/persona-pack.schema.json +21 -0
- package/config/persona.schema.json +17 -0
- package/config/policy-evaluation.schema.json +77 -0
- package/config/policy-facts.schema.json +140 -0
- package/config/portfolio.schema.json +68 -0
- package/config/project.schema.json +313 -0
- package/config/prototype-iteration.schema.json +128 -0
- package/config/rollout.schema.json +87 -0
- package/config/security-adapter.schema.json +31 -0
- package/config/security-scan-request.schema.json +64 -0
- package/config/security-scan-response.schema.json +52 -0
- package/config/security-validation-policy.schema.json +74 -0
- package/config/starter-source-acknowledgement.schema.json +13 -0
- package/config/starter-source-adapter.schema.json +38 -0
- package/config/starter-source-request.schema.json +61 -0
- package/package.json +77 -0
- package/packs/core/pack.yaml +7 -0
- package/packs/design-systems/default/experience-promise.md +9 -0
- package/packs/design-systems/default/intentional-review.md +10 -0
- package/packs/design-systems/default/interaction-and-entry.md +9 -0
- package/packs/design-systems/default/meaningful-content-and-states.md +9 -0
- package/packs/design-systems/default/pack.yaml +44 -0
- package/packs/design-systems/default/principles.md +10 -0
- package/packs/personas/core/pack.yaml +7 -0
- package/packs/personas/core/personas/archaeologist.md +37 -0
- package/packs/personas/core/personas/end-user.md +17 -0
- package/packs/personas/core/personas/maintainer.md +17 -0
- package/packs/personas/core/personas/operator.md +17 -0
- package/packs/personas/core/personas/specs-knowledge-curator.md +35 -0
- package/packs/technologies/laravel/pack.yaml +30 -0
- package/packs/technologies/laravel-nuxt/pack.yaml +30 -0
- package/packs/technologies/nuxt/pack.yaml +30 -0
- package/packs/technologies/power-platform/pack.yaml +31 -0
- package/packs/technologies/salesforce/pack.yaml +25 -0
- package/public/app.js +4896 -0
- package/public/apple-touch-icon.png +0 -0
- package/public/assets/backstory-icon.png +0 -0
- package/public/dashboard-navigation.js +98 -0
- package/public/favicon-16.png +0 -0
- package/public/favicon-32.png +0 -0
- package/public/favicon.ico +0 -0
- package/public/index.html +789 -0
- package/public/styles.css +2693 -0
- package/public/team-hub/app.js +202 -0
- package/public/team-hub/index.html +79 -0
- package/public/team-hub/styles.css +90 -0
- package/scripts/publication-check.mjs +140 -0
- package/scripts/setup.mjs +21 -0
- package/skills-src/ewai-archaeology/SKILL.md +334 -0
- package/skills-src/ewai-archaeology/agents/openai.yaml +4 -0
- package/skills-src/ewai-archaeology/references/archaeology-contract.md +201 -0
- package/skills-src/ewai-archaeology/references/lifecycle-reconstruction.md +177 -0
- package/skills-src/ewai-archaeology/references/maximum-detail-reconstruction.md +97 -0
- package/skills-src/ewai-archaeology/references/model-routing.md +26 -0
- package/skills-src/ewai-architecture/SKILL.md +108 -0
- package/skills-src/ewai-architecture/agents/openai.yaml +4 -0
- package/skills-src/ewai-architecture/references/architecture-contract.md +176 -0
- package/skills-src/ewai-context/SKILL.md +68 -0
- package/skills-src/ewai-context/agents/openai.yaml +4 -0
- package/skills-src/ewai-context-import/SKILL.md +118 -0
- package/skills-src/ewai-context-import/agents/openai.yaml +4 -0
- package/skills-src/ewai-context-import/references/context-import-contract.md +106 -0
- package/skills-src/ewai-dashboard-configuration/SKILL.md +20 -0
- package/skills-src/ewai-deliver/SKILL.md +122 -0
- package/skills-src/ewai-deliver/references/delivery-evidence.md +92 -0
- package/skills-src/ewai-deliver/references/phase-routing.md +31 -0
- package/skills-src/ewai-design-system-apply/SKILL.md +27 -0
- package/skills-src/ewai-design-system-apply/agents/openai.yaml +4 -0
- package/skills-src/ewai-design-system-apply/references/application-contract.md +36 -0
- package/skills-src/ewai-design-system-author/SKILL.md +28 -0
- package/skills-src/ewai-design-system-author/agents/openai.yaml +4 -0
- package/skills-src/ewai-design-system-author/references/authoring-contract.md +38 -0
- package/skills-src/ewai-design-system-review/SKILL.md +26 -0
- package/skills-src/ewai-design-system-review/agents/openai.yaml +4 -0
- package/skills-src/ewai-design-system-review/references/review-contract.md +40 -0
- package/skills-src/ewai-error-reporting/SKILL.md +46 -0
- package/skills-src/ewai-error-reporting/agents/openai.yaml +4 -0
- package/skills-src/ewai-error-reporting/references/provider-contract.md +74 -0
- package/skills-src/ewai-evidence-depth/SKILL.md +72 -0
- package/skills-src/ewai-evidence-depth/agents/openai.yaml +4 -0
- package/skills-src/ewai-evidence-depth/references/evidence-depth-contract.md +127 -0
- package/skills-src/ewai-intent/SKILL.md +68 -0
- package/skills-src/ewai-intent/agents/openai.yaml +4 -0
- package/skills-src/ewai-intent/references/intent-contract.md +42 -0
- package/skills-src/ewai-knowledge-proposals/SKILL.md +105 -0
- package/skills-src/ewai-knowledge-proposals/agents/openai.yaml +4 -0
- package/skills-src/ewai-knowledge-proposals/references/proposal-contract.md +59 -0
- package/skills-src/ewai-meeting-evidence/SKILL.md +106 -0
- package/skills-src/ewai-meeting-evidence/agents/openai.yaml +4 -0
- package/skills-src/ewai-meeting-evidence/references/candidate-contract.md +64 -0
- package/skills-src/ewai-organisation-policy/SKILL.md +62 -0
- package/skills-src/ewai-organisation-policy/agents/openai.yaml +4 -0
- package/skills-src/ewai-organisation-policy/references/policy-contract.md +94 -0
- package/skills-src/ewai-palace-housekeeping/SKILL.md +55 -0
- package/skills-src/ewai-palace-housekeeping/agents/openai.yaml +4 -0
- package/skills-src/ewai-persona-entitlement/SKILL.md +60 -0
- package/skills-src/ewai-persona-entitlement/agents/openai.yaml +4 -0
- package/skills-src/ewai-phase-evidence/SKILL.md +79 -0
- package/skills-src/ewai-phase-evidence/agents/openai.yaml +4 -0
- package/skills-src/ewai-pipeline/SKILL.md +130 -0
- package/skills-src/ewai-pipeline/agents/openai.yaml +4 -0
- package/skills-src/ewai-pipeline/references/cli.md +86 -0
- package/skills-src/ewai-pipeline/references/specs-contract.md +16 -0
- package/skills-src/ewai-portfolio/SKILL.md +70 -0
- package/skills-src/ewai-portfolio/agents/openai.yaml +4 -0
- package/skills-src/ewai-portfolio/references/portfolio-contract.md +67 -0
- package/skills-src/ewai-project-discovery/SKILL.md +95 -0
- package/skills-src/ewai-project-discovery/agents/openai.yaml +4 -0
- package/skills-src/ewai-project-discovery/references/discovery-contract.md +34 -0
- package/skills-src/ewai-prototype-iteration/SKILL.md +30 -0
- package/skills-src/ewai-prototype-iteration/agents/openai.yaml +4 -0
- package/skills-src/ewai-prototype-iteration/references/review-contract.md +49 -0
- package/skills-src/ewai-retro/SKILL.md +48 -0
- package/skills-src/ewai-retro/agents/openai.yaml +4 -0
- package/skills-src/ewai-retro/references/asset-routing.md +14 -0
- package/skills-src/ewai-rollout/SKILL.md +74 -0
- package/skills-src/ewai-rollout/agents/openai.yaml +4 -0
- package/skills-src/ewai-rollout/references/rollout-contract.md +74 -0
- package/skills-src/ewai-shape-intents/SKILL.md +84 -0
- package/skills-src/ewai-shape-intents/agents/openai.yaml +4 -0
- package/skills-src/ewai-shape-intents/references/intent-mapping-contract.md +109 -0
- package/skills-src/ewai-solution-readiness/SKILL.md +55 -0
- package/skills-src/ewai-solution-readiness/agents/openai.yaml +4 -0
- package/skills-src/ewai-standards-check/SKILL.md +93 -0
- package/skills-src/ewai-standards-check/agents/openai.yaml +4 -0
- package/skills-src/ewai-standards-check/references/report-contract.md +116 -0
- package/skills-src/ewai-test-scenarios/SKILL.md +94 -0
- package/skills-src/ewai-test-scenarios/agents/openai.yaml +4 -0
- package/skills-src/ewai-test-scenarios/references/scenario-contract.md +88 -0
- package/src/afk-worker.mjs +16 -0
- package/src/archaeology.mjs +1333 -0
- package/src/checkin.mjs +261 -0
- package/src/cli.mjs +2427 -0
- package/src/companion-guidance.mjs +257 -0
- package/src/companion-opening.mjs +62 -0
- package/src/companion.mjs +256 -0
- package/src/context.mjs +210 -0
- package/src/dashboard-preferences.mjs +80 -0
- package/src/delivery-artifacts.mjs +204 -0
- package/src/delivery-documents.mjs +248 -0
- package/src/delivery-gates.mjs +317 -0
- package/src/delivery.mjs +1433 -0
- package/src/design-system-application.mjs +291 -0
- package/src/design-system-authoring.mjs +101 -0
- package/src/design-systems.mjs +466 -0
- package/src/discovery.mjs +1314 -0
- package/src/error-reporting.mjs +323 -0
- package/src/evidence-depth.mjs +543 -0
- package/src/execution-state.mjs +243 -0
- package/src/install.mjs +166 -0
- package/src/intent-dependencies.mjs +117 -0
- package/src/intent-maps.mjs +402 -0
- package/src/intents.mjs +747 -0
- package/src/knowledge-proposals.mjs +717 -0
- package/src/launcher.mjs +51 -0
- package/src/meeting-evidence.mjs +703 -0
- package/src/network-rollout.mjs +386 -0
- package/src/organisation-blueprints.mjs +438 -0
- package/src/organisation-policies.mjs +448 -0
- package/src/packs.mjs +44 -0
- package/src/paths.mjs +62 -0
- package/src/persona-entitlements.mjs +438 -0
- package/src/persona-licence-config.mjs +98 -0
- package/src/persona-website-provider.mjs +134 -0
- package/src/persona-zip.mjs +87 -0
- package/src/personas.mjs +159 -0
- package/src/platform-metadata-analysis.mjs +314 -0
- package/src/policy-design-gates.mjs +623 -0
- package/src/policy-gate-integration.mjs +318 -0
- package/src/portfolio.mjs +509 -0
- package/src/power-platform-source-map.mjs +190 -0
- package/src/project.mjs +449 -0
- package/src/prototype-iterations.mjs +730 -0
- package/src/repository-source-map.mjs +603 -0
- package/src/runtime/afk-conductor.mjs +973 -0
- package/src/runtime/context-assembly.mjs +457 -0
- package/src/runtime/context-benchmarks.mjs +115 -0
- package/src/runtime/dashboard-actions.mjs +109 -0
- package/src/runtime/dashboard-handoffs.mjs +149 -0
- package/src/runtime/dashboard-server.mjs +1272 -0
- package/src/runtime/dashboard.mjs +197 -0
- package/src/runtime/database.mjs +789 -0
- package/src/runtime/error-reporting.mjs +581 -0
- package/src/runtime/evidence-depth-workspace.mjs +412 -0
- package/src/runtime/execution-leases.mjs +299 -0
- package/src/runtime/guided-discovery.mjs +350 -0
- package/src/runtime/guided-intents.mjs +517 -0
- package/src/runtime/impact-analysis.mjs +535 -0
- package/src/runtime/intents.mjs +222 -0
- package/src/runtime/knowledge.mjs +86 -0
- package/src/runtime/lifecycle-hooks.mjs +1239 -0
- package/src/runtime/mcp-config.mjs +110 -0
- package/src/runtime/mcp-server.mjs +1885 -0
- package/src/runtime/palace.mjs +362 -0
- package/src/runtime/paths.mjs +58 -0
- package/src/runtime/persona-engagement.mjs +255 -0
- package/src/runtime/phase-contributions.mjs +594 -0
- package/src/runtime/policy-workspace.mjs +170 -0
- package/src/runtime/prototype-iterations.mjs +235 -0
- package/src/runtime/provider-adapters.mjs +163 -0
- package/src/runtime/repository-index.mjs +838 -0
- package/src/runtime/runs.mjs +185 -0
- package/src/runtime/security-validation.mjs +1230 -0
- package/src/runtime/starter-materialisation.mjs +1155 -0
- package/src/runtime/team-hub-client.mjs +479 -0
- package/src/runtime/team-hub-database.mjs +288 -0
- package/src/runtime/team-hub-server.mjs +191 -0
- package/src/runtime/team-hub.mjs +110 -0
- package/src/runtime/tree-sitter-index.mjs +390 -0
- package/src/runtime/version.mjs +1 -0
- package/src/runtime/work.mjs +633 -0
- package/src/salesforce-source-map.mjs +212 -0
- package/src/security-validation-config.mjs +224 -0
- package/src/solution-readiness.mjs +620 -0
- package/src/starter-materialisation-contract.mjs +407 -0
- package/src/task-graph.mjs +544 -0
- package/src/team-hub-resources.mjs +239 -0
- package/src/team-hub.mjs +242 -0
- package/src/test-scenarios.mjs +622 -0
- package/src/validation-config.mjs +289 -0
- package/templates/SPECS/1.Scope/personas/registry.yaml +12 -0
- package/templates/SPECS/5.Strategy/patterns/context-packet.md +119 -0
- package/templates/SPECS/6.Build/_tracker-template.md +16 -0
- package/templates/SPECS/pipeline.yaml +62 -0
- package/templates/discovery-answers.yaml +86 -0
- package/templates/intent-body.md +21 -0
- package/tests/fixtures/context-benchmarks.json +9 -0
|
@@ -0,0 +1,390 @@
|
|
|
1
|
+
import Parser from 'tree-sitter';
|
|
2
|
+
import Php from 'tree-sitter-php';
|
|
3
|
+
import JavaScript from 'tree-sitter-javascript';
|
|
4
|
+
import TypeScript from 'tree-sitter-typescript';
|
|
5
|
+
import { extname } from 'node:path';
|
|
6
|
+
|
|
7
|
+
const parserVersion = 'tree-sitter@0.21.1';
|
|
8
|
+
const maxSnippetLength = 320;
|
|
9
|
+
|
|
10
|
+
const languages = {
|
|
11
|
+
php: Php.php,
|
|
12
|
+
js: JavaScript,
|
|
13
|
+
ts: TypeScript.typescript,
|
|
14
|
+
tsx: TypeScript.tsx
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
function parserFor(language) {
|
|
18
|
+
const grammar = languages[language];
|
|
19
|
+
if (!grammar) return null;
|
|
20
|
+
const parser = new Parser();
|
|
21
|
+
parser.setLanguage(grammar);
|
|
22
|
+
return parser;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function languageForPath(path) {
|
|
26
|
+
const extension = extname(path);
|
|
27
|
+
if (extension === '.php') return 'php';
|
|
28
|
+
if (['.js', '.mjs', '.cjs', '.jsx'].includes(extension)) return 'js';
|
|
29
|
+
if (['.ts', '.mts', '.cts'].includes(extension)) return 'ts';
|
|
30
|
+
if (extension === '.tsx') return 'tsx';
|
|
31
|
+
if (extension === '.vue') return 'vue';
|
|
32
|
+
return '';
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function parseJson(value, fallback) {
|
|
36
|
+
try {
|
|
37
|
+
return JSON.parse(value);
|
|
38
|
+
} catch {
|
|
39
|
+
return fallback;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function lineCount(content) {
|
|
44
|
+
return content ? content.split(/\r?\n/).length : 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
function pointLine(point) {
|
|
48
|
+
return Number(point?.row ?? 0) + 1;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function childText(node, type) {
|
|
52
|
+
const child = node.namedChildren.find((candidate) => candidate.type === type);
|
|
53
|
+
return child?.text ?? '';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function childByType(node, type) {
|
|
57
|
+
return node.namedChildren.find((candidate) => candidate.type === type) ?? null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function namedDescendants(node, types, results = []) {
|
|
61
|
+
if (types.has(node.type)) results.push(node);
|
|
62
|
+
for (const child of node.namedChildren) namedDescendants(child, types, results);
|
|
63
|
+
return results;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function firstNamedDescendant(node, types) {
|
|
67
|
+
if (types.has(node.type)) return node;
|
|
68
|
+
for (const child of node.namedChildren) {
|
|
69
|
+
const found = firstNamedDescendant(child, types);
|
|
70
|
+
if (found) return found;
|
|
71
|
+
}
|
|
72
|
+
return null;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function snippetFor(node) {
|
|
76
|
+
return String(node.text ?? '').replace(/\s+/g, ' ').trim().slice(0, maxSnippetLength);
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function spanFor(repo, path, symbol, node, metadata = {}) {
|
|
80
|
+
return {
|
|
81
|
+
repo,
|
|
82
|
+
path,
|
|
83
|
+
symbolKind: symbol.kind,
|
|
84
|
+
symbolName: symbol.name,
|
|
85
|
+
startLine: pointLine(node.startPosition),
|
|
86
|
+
endLine: pointLine(node.endPosition),
|
|
87
|
+
startByte: node.startIndex ?? 0,
|
|
88
|
+
endByte: node.endIndex ?? 0,
|
|
89
|
+
evidenceSnippet: snippetFor(node),
|
|
90
|
+
parser: parserVersion,
|
|
91
|
+
metadata
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function withLineOffset(node, offset) {
|
|
96
|
+
return {
|
|
97
|
+
type: node.type,
|
|
98
|
+
text: node.text,
|
|
99
|
+
startIndex: node.startIndex,
|
|
100
|
+
endIndex: node.endIndex,
|
|
101
|
+
startPosition: { ...node.startPosition, row: node.startPosition.row + offset },
|
|
102
|
+
endPosition: { ...node.endPosition, row: node.endPosition.row + offset }
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
function importRecord(repo, path, sourceModule, importedName, localName, importKind, line, metadata = {}) {
|
|
107
|
+
return {
|
|
108
|
+
repo,
|
|
109
|
+
path,
|
|
110
|
+
sourceModule,
|
|
111
|
+
importedName,
|
|
112
|
+
localName,
|
|
113
|
+
importKind,
|
|
114
|
+
line,
|
|
115
|
+
parser: parserVersion,
|
|
116
|
+
metadata
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
function symbolRecord(repo, kind, name, path, node, tags = [], metadata = {}) {
|
|
121
|
+
return {
|
|
122
|
+
repo,
|
|
123
|
+
kind,
|
|
124
|
+
name,
|
|
125
|
+
line: pointLine(node.startPosition),
|
|
126
|
+
signature: snippetFor(node),
|
|
127
|
+
tags,
|
|
128
|
+
metadata: {
|
|
129
|
+
...metadata,
|
|
130
|
+
parser: parserVersion
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
function relationshipRecord(sourceKind, sourceName, sourcePath, relationshipKind, targetKind, targetName, targetPath = '', metadata = {}) {
|
|
136
|
+
return {
|
|
137
|
+
source_kind: sourceKind,
|
|
138
|
+
source_name: sourceName,
|
|
139
|
+
source_path: sourcePath,
|
|
140
|
+
relationship_kind: relationshipKind,
|
|
141
|
+
target_kind: targetKind,
|
|
142
|
+
target_name: targetName,
|
|
143
|
+
target_path: targetPath,
|
|
144
|
+
metadata: {
|
|
145
|
+
...metadata,
|
|
146
|
+
parser: parserVersion
|
|
147
|
+
}
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function phpClassName(node) {
|
|
152
|
+
return childText(node, 'name');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
function collectPhp(repo, path, tree) {
|
|
156
|
+
const symbols = [];
|
|
157
|
+
const relationships = [];
|
|
158
|
+
const imports = [];
|
|
159
|
+
const spans = [];
|
|
160
|
+
const root = tree.rootNode;
|
|
161
|
+
|
|
162
|
+
for (const node of namedDescendants(root, new Set(['namespace_use_declaration']))) {
|
|
163
|
+
for (const qualified of namedDescendants(node, new Set(['qualified_name']))) {
|
|
164
|
+
const sourceModule = qualified.text;
|
|
165
|
+
const importedName = sourceModule.split('\\').pop() ?? sourceModule;
|
|
166
|
+
imports.push(importRecord(repo, path, sourceModule, importedName, importedName, 'php_use', pointLine(node.startPosition)));
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const classNodes = namedDescendants(root, new Set(['class_declaration', 'trait_declaration', 'interface_declaration']));
|
|
171
|
+
for (const classNode of classNodes) {
|
|
172
|
+
const className = phpClassName(classNode);
|
|
173
|
+
if (!className) continue;
|
|
174
|
+
const classSymbol = symbolRecord(repo, 'php_class', className, path, classNode, [repo, 'php', 'class'], {
|
|
175
|
+
declaration_type: classNode.type
|
|
176
|
+
});
|
|
177
|
+
symbols.push(classSymbol);
|
|
178
|
+
spans.push(spanFor(repo, path, classSymbol, classNode, { declaration_type: classNode.type }));
|
|
179
|
+
|
|
180
|
+
for (const methodNode of namedDescendants(classNode, new Set(['method_declaration']))) {
|
|
181
|
+
const methodName = childText(methodNode, 'name');
|
|
182
|
+
if (!methodName) continue;
|
|
183
|
+
const methodSymbol = symbolRecord(repo, 'php_method', `${className}::${methodName}`, path, methodNode, [repo, 'php', 'method'], {
|
|
184
|
+
class_name: className,
|
|
185
|
+
method: methodName,
|
|
186
|
+
visibility: childByType(methodNode, 'visibility_modifier')?.text ?? ''
|
|
187
|
+
});
|
|
188
|
+
symbols.push(methodSymbol);
|
|
189
|
+
spans.push(spanFor(repo, path, methodSymbol, methodNode, { class_name: className, method: methodName }));
|
|
190
|
+
relationships.push(relationshipRecord('php_class', className, path, 'declares_method', 'php_method', methodSymbol.name, path));
|
|
191
|
+
|
|
192
|
+
if (/\$this->authorize\s*\(/.test(methodNode.text)) {
|
|
193
|
+
relationships.push(relationshipRecord('php_method', methodSymbol.name, path, 'uses_authorization', 'policy_ability', '$this->authorize'));
|
|
194
|
+
}
|
|
195
|
+
for (const match of methodNode.text.matchAll(/\bnew\s+([A-Za-z0-9_]+Resource)\b/g)) {
|
|
196
|
+
relationships.push(relationshipRecord('php_method', methodSymbol.name, path, 'returns_resource', 'resource', match[1]));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
return { symbols, relationships, imports, spans };
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
function stringLiteralValue(node) {
|
|
205
|
+
const fragment = firstNamedDescendant(node, new Set(['string_fragment']));
|
|
206
|
+
if (fragment) return fragment.text;
|
|
207
|
+
return node.text.replace(/^['"`]|['"`]$/g, '');
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
function collectJsTs(repo, path, tree, sourceText, options = {}) {
|
|
211
|
+
const symbols = [];
|
|
212
|
+
const relationships = [];
|
|
213
|
+
const imports = [];
|
|
214
|
+
const spans = [];
|
|
215
|
+
const root = tree.rootNode;
|
|
216
|
+
const lineOffset = Number(options.lineOffset ?? 0);
|
|
217
|
+
|
|
218
|
+
for (const node of namedDescendants(root, new Set(['import_statement']))) {
|
|
219
|
+
const sourceNode = childByType(node, 'string');
|
|
220
|
+
const sourceModule = sourceNode ? stringLiteralValue(sourceNode) : '';
|
|
221
|
+
if (!sourceModule) continue;
|
|
222
|
+
const names = namedDescendants(node, new Set(['import_specifier', 'identifier']))
|
|
223
|
+
.map((candidate) => candidate.text)
|
|
224
|
+
.filter((value) => value && !value.includes('/') && value !== sourceModule);
|
|
225
|
+
if (!names.length) {
|
|
226
|
+
imports.push(importRecord(repo, path, sourceModule, '', '', 'module', pointLine(node.startPosition) + lineOffset));
|
|
227
|
+
continue;
|
|
228
|
+
}
|
|
229
|
+
for (const name of [...new Set(names)]) {
|
|
230
|
+
imports.push(importRecord(repo, path, sourceModule, name, name, 'esm', pointLine(node.startPosition) + lineOffset));
|
|
231
|
+
const targetKind = sourceModule.includes('/stores/') || sourceModule.includes('stores/') ? 'store'
|
|
232
|
+
: sourceModule.includes('/services/api') || sourceModule.includes('services/api') ? 'service'
|
|
233
|
+
: sourceModule.includes('/components/') || sourceModule.includes('components/') ? 'component'
|
|
234
|
+
: 'module';
|
|
235
|
+
relationships.push(relationshipRecord('file', path, path, 'imports', targetKind, name, sourceModule));
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
for (const node of namedDescendants(root, new Set(['function_declaration']))) {
|
|
240
|
+
const name = childText(node, 'identifier') || childText(node, 'property_identifier');
|
|
241
|
+
if (!name) continue;
|
|
242
|
+
const adjustedNode = withLineOffset(node, lineOffset);
|
|
243
|
+
const symbol = symbolRecord(repo, 'ts_function', name, path, adjustedNode, [repo, 'typescript', 'function']);
|
|
244
|
+
symbols.push(symbol);
|
|
245
|
+
spans.push(spanFor(repo, path, symbol, adjustedNode));
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
for (const node of namedDescendants(root, new Set(['variable_declarator']))) {
|
|
249
|
+
const nameNode = childByType(node, 'identifier');
|
|
250
|
+
if (!nameNode) continue;
|
|
251
|
+
const name = nameNode.text;
|
|
252
|
+
const adjustedNode = withLineOffset(node, lineOffset);
|
|
253
|
+
const text = node.text;
|
|
254
|
+
if (/defineStore\s*\(/.test(text)) {
|
|
255
|
+
const id = text.match(/defineStore\s*\(\s*['"]([^'"]+)['"]/)?.[1] ?? name;
|
|
256
|
+
const symbol = symbolRecord(repo, 'store', id, path, adjustedNode, [repo, 'typescript', 'pinia', 'store'], {
|
|
257
|
+
local_name: name
|
|
258
|
+
});
|
|
259
|
+
symbols.push(symbol);
|
|
260
|
+
spans.push(spanFor(repo, path, symbol, adjustedNode, { local_name: name }));
|
|
261
|
+
continue;
|
|
262
|
+
}
|
|
263
|
+
if (/=>\s*|function\s*\(|async\s*\(/.test(text)) {
|
|
264
|
+
const symbol = symbolRecord(repo, 'ts_function', name, path, adjustedNode, [repo, 'typescript', 'function'], {
|
|
265
|
+
declaration: 'variable_declarator'
|
|
266
|
+
});
|
|
267
|
+
symbols.push(symbol);
|
|
268
|
+
spans.push(spanFor(repo, path, symbol, adjustedNode));
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
for (const match of sourceText.matchAll(/\b(use[A-Z][A-Za-z0-9]+Store)\s*\(/g)) {
|
|
273
|
+
relationships.push(relationshipRecord('file', path, path, 'uses_store', 'store_factory', match[1], '', {
|
|
274
|
+
line: sourceText.slice(0, match.index).split(/\r?\n/).length + lineOffset
|
|
275
|
+
}));
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
for (const match of sourceText.matchAll(/\b([A-Za-z0-9_]+Service)\.([A-Za-z0-9_]+)\s*\(/g)) {
|
|
279
|
+
relationships.push(relationshipRecord('file', path, path, 'calls_service_method', 'service_method', `${match[1]}.${match[2]}`, '', {
|
|
280
|
+
line: sourceText.slice(0, match.index).split(/\r?\n/).length + lineOffset
|
|
281
|
+
}));
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
return { symbols, relationships, imports, spans };
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function scriptBlocks(content) {
|
|
288
|
+
const blocks = [];
|
|
289
|
+
const regex = /<script\b[^>]*>([\s\S]*?)<\/script>/gi;
|
|
290
|
+
let match;
|
|
291
|
+
while ((match = regex.exec(content)) !== null) {
|
|
292
|
+
const before = content.slice(0, match.index);
|
|
293
|
+
blocks.push({
|
|
294
|
+
content: match[1],
|
|
295
|
+
lineOffset: before.split(/\r?\n/).length - 1
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
return blocks;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
function collectVueTemplate(repo, path, content) {
|
|
302
|
+
const symbols = [];
|
|
303
|
+
const relationships = [];
|
|
304
|
+
const imports = [];
|
|
305
|
+
const spans = [];
|
|
306
|
+
const componentNames = new Set();
|
|
307
|
+
const tagRegex = /<\/?([A-Z][A-Za-z0-9]*(?:\.[A-Za-z0-9]+)?)\b/g;
|
|
308
|
+
let match;
|
|
309
|
+
while ((match = tagRegex.exec(content)) !== null) {
|
|
310
|
+
componentNames.add(match[1]);
|
|
311
|
+
relationships.push(relationshipRecord('vue_page', path, path, 'uses_component', 'component', match[1], '', {
|
|
312
|
+
line: content.slice(0, match.index).split(/\r?\n/).length,
|
|
313
|
+
parser_fallback: 'template-tag-scan'
|
|
314
|
+
}));
|
|
315
|
+
}
|
|
316
|
+
for (const componentName of componentNames) {
|
|
317
|
+
imports.push(importRecord(repo, path, '', componentName, componentName, 'vue_template_component', null, {
|
|
318
|
+
parser_fallback: 'template-tag-scan'
|
|
319
|
+
}));
|
|
320
|
+
}
|
|
321
|
+
return { symbols, relationships, imports, spans };
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
function mergeFacts(...facts) {
|
|
325
|
+
return facts.reduce((merged, fact) => ({
|
|
326
|
+
symbols: [...merged.symbols, ...(fact.symbols ?? [])],
|
|
327
|
+
relationships: [...merged.relationships, ...(fact.relationships ?? [])],
|
|
328
|
+
imports: [...merged.imports, ...(fact.imports ?? [])],
|
|
329
|
+
spans: [...merged.spans, ...(fact.spans ?? [])]
|
|
330
|
+
}), { symbols: [], relationships: [], imports: [], spans: [] });
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
export function extractTreeSitterFacts(path, content, context) {
|
|
334
|
+
const language = languageForPath(path);
|
|
335
|
+
const repo = context.repo;
|
|
336
|
+
const relativePath = context.repoRelative(path);
|
|
337
|
+
const file = {
|
|
338
|
+
repo,
|
|
339
|
+
path: relativePath,
|
|
340
|
+
language,
|
|
341
|
+
parser: parserVersion,
|
|
342
|
+
parserStatus: language ? 'parsed' : 'not_applicable',
|
|
343
|
+
sizeBytes: Buffer.byteLength(content),
|
|
344
|
+
lineCount: lineCount(content),
|
|
345
|
+
parseErrorCount: 0,
|
|
346
|
+
metadata: {}
|
|
347
|
+
};
|
|
348
|
+
|
|
349
|
+
if (!language) return { file, symbols: [], relationships: [], imports: [], spans: [] };
|
|
350
|
+
|
|
351
|
+
try {
|
|
352
|
+
if (language === 'php') {
|
|
353
|
+
const parser = parserFor('php');
|
|
354
|
+
const tree = parser.parse(content);
|
|
355
|
+
file.parseErrorCount = Number(tree.rootNode.hasError);
|
|
356
|
+
return { file, ...collectPhp(repo, relativePath, tree) };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if (language === 'js' || language === 'ts' || language === 'tsx') {
|
|
360
|
+
const parser = parserFor(language);
|
|
361
|
+
const tree = parser.parse(content);
|
|
362
|
+
file.parseErrorCount = Number(tree.rootNode.hasError);
|
|
363
|
+
return { file, ...collectJsTs(repo, relativePath, tree, content) };
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
if (language === 'vue') {
|
|
367
|
+
const parser = parserFor('ts');
|
|
368
|
+
const facts = [];
|
|
369
|
+
for (const block of scriptBlocks(content)) {
|
|
370
|
+
const tree = parser.parse(block.content);
|
|
371
|
+
file.parseErrorCount += Number(tree.rootNode.hasError);
|
|
372
|
+
facts.push(collectJsTs(repo, relativePath, tree, block.content, { lineOffset: block.lineOffset }));
|
|
373
|
+
}
|
|
374
|
+
facts.push(collectVueTemplate(repo, relativePath, content));
|
|
375
|
+
file.metadata = { vue_script_blocks: facts.length - 1 };
|
|
376
|
+
return { file, ...mergeFacts(...facts) };
|
|
377
|
+
}
|
|
378
|
+
} catch {
|
|
379
|
+
file.parserStatus = 'failed';
|
|
380
|
+
file.parseErrorCount = 1;
|
|
381
|
+
file.metadata = { failure_code: 'tree-sitter-analysis-failed' };
|
|
382
|
+
return { file, symbols: [], relationships: [], imports: [], spans: [] };
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
return { file, symbols: [], relationships: [], imports: [], spans: [] };
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export function parseStoredJson(value, fallback) {
|
|
389
|
+
return parseJson(value, fallback);
|
|
390
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const dashboardRuntimeVersion = 11;
|