@tiinex/core 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/NOTICE +31 -0
- package/README.md +45 -0
- package/package.json +176 -0
- package/src/actions/record.actions.js +312 -0
- package/src/adapters/adapter.contracts.js +143 -0
- package/src/adapters/archive/archive.adapter.js +502 -0
- package/src/adapters/archive/archive.portableChangeset.js +141 -0
- package/src/adapters/archive/archive.transport.js +124 -0
- package/src/artifacts/artifact.localDraft.js +27 -0
- package/src/artifacts/artifact.normalize.js +28 -0
- package/src/artifacts/artifact.parse.js +207 -0
- package/src/artifacts/artifact.record.js +83 -0
- package/src/audit/audit.run.js +103 -0
- package/src/audit/audit.summary.js +7 -0
- package/src/diagnostics/sourceBoundary.report.js +112 -0
- package/src/export/package.apply.js +349 -0
- package/src/export/package.builder.js +366 -0
- package/src/export/package.bytes.js +164 -0
- package/src/export/package.controlIntegrity.js +42 -0
- package/src/export/package.controlTopology.js +97 -0
- package/src/export/package.fileMap.js +174 -0
- package/src/export/package.manifest.js +401 -0
- package/src/export/package.preflight.js +204 -0
- package/src/export/package.sourceReference.js +81 -0
- package/src/export/package.workspaceContext.js +144 -0
- package/src/export/package.zip.js +128 -0
- package/src/export/tree.bundle.js +278 -0
- package/src/governance/governance.boundary.js +196 -0
- package/src/integrity/integrity.c14nV2.js +190 -0
- package/src/integrity/integrity.methodReference.js +73 -0
- package/src/integrity/integrity.validate.js +56 -0
- package/src/lineage/lineage.candidateResolution.js +46 -0
- package/src/lineage/lineage.githubIssueComment.js +106 -0
- package/src/lineage/lineage.githubIssueLocal.js +196 -0
- package/src/lineage/lineage.githubIssueTarget.js +89 -0
- package/src/lineage/lineage.integrity.js +133 -0
- package/src/lineage/lineage.materialPreference.js +26 -0
- package/src/lineage/lineage.model.js +63 -0
- package/src/lineage/lineage.parentAuthority.js +5 -0
- package/src/lineage/lineage.parentBinding.js +104 -0
- package/src/lineage/lineage.pathBasis.js +47 -0
- package/src/lineage/lineage.resolve.js +388 -0
- package/src/lineage/lineage.sourceScope.js +74 -0
- package/src/lineage/lineage.targetKeys.js +80 -0
- package/src/lineage/lineage.traverse.js +132 -0
- package/src/public/applicationProjection.js +236 -0
- package/src/public/companionResources.js +246 -0
- package/src/public/index.js +16 -0
- package/src/public/node.js +2 -0
- package/src/public/schemaAncestry.js +26 -0
- package/src/publication/publication.contract.js +196 -0
- package/src/publication/publication.preflight.js +159 -0
- package/src/publication/publication.targetContract.js +241 -0
- package/src/reingest/reingest.plan.js +162 -0
- package/src/release/plan.mjs +28 -0
- package/src/release/policy.mjs +100 -0
- package/src/release/run.mjs +74 -0
- package/src/schemas/capability.registry.js +226 -0
- package/src/schemas/companion.js +245 -0
- package/src/schemas/contracts.js +6 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.js +14 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.json +23 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.runtime.json +4283 -0
- package/src/schemas/coordination/handoff/tiinex.handoff.v1.schema.source.js +9 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.js +26 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.json +23 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.runtime.json +1985 -0
- package/src/schemas/coordination/project/tiinex.project.v1.schema.source.js +9 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.js +14 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.json +24 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.runtime.json +1700 -0
- package/src/schemas/core/decision/tiinex.decision.v1.schema.source.js +9 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.capabilities.js +14 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.en.i18n.json +6 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.findings.js +9 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.presenter.js +1 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.js +32 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.json +24 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.runtime.json +2184 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.schema.source.js +9 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.sv.i18n.json +6 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.transitions.js +1 -0
- package/src/schemas/core/evidence/tiinex.evidence.v1.validate.js +10 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.js +14 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.json +23 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.runtime.json +1773 -0
- package/src/schemas/core/feedback/tiinex.feedback.v1.schema.source.js +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.capabilities.js +11 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.contract.js +40 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.en.i18n.json +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.findings.js +12 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.localMaterialization.js +89 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.presenter.js +8 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.js +34 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.json +23 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.runtime.json +2029 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.schema.source.js +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.sv.i18n.json +9 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.transitions.js +1 -0
- package/src/schemas/core/interpretation/tiinex.interpretation.v1.validate.js +25 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.capabilities.js +14 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.en.i18n.json +6 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.findings.js +9 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.presenter.js +1 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.js +31 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.json +23 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.runtime.json +2033 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.schema.source.js +9 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.sv.i18n.json +6 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.transitions.js +1 -0
- package/src/schemas/core/preservation/tiinex.preservation.v1.validate.js +10 -0
- package/src/schemas/core/relation/tiinex.relation.v1.capabilities.js +7 -0
- package/src/schemas/core/relation/tiinex.relation.v1.contract.js +3 -0
- package/src/schemas/core/relation/tiinex.relation.v1.en.i18n.json +4 -0
- package/src/schemas/core/relation/tiinex.relation.v1.findings.js +9 -0
- package/src/schemas/core/relation/tiinex.relation.v1.localMaterialization.js +153 -0
- package/src/schemas/core/relation/tiinex.relation.v1.presenter.js +3 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.js +20 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.json +23 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.runtime.json +1668 -0
- package/src/schemas/core/relation/tiinex.relation.v1.schema.source.js +9 -0
- package/src/schemas/core/relation/tiinex.relation.v1.sv.i18n.json +4 -0
- package/src/schemas/core/relation/tiinex.relation.v1.transitions.js +1 -0
- package/src/schemas/core/relation/tiinex.relation.v1.validate.js +36 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.capabilities.js +14 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.contract.js +57 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.en.i18n.json +4 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.findings.js +13 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.presenter.js +3 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.js +20 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.json +24 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.runtime.json +3315 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.schema.source.js +9 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.sv.i18n.json +4 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.transitions.js +1 -0
- package/src/schemas/core/relation/workspace/representation/tiinex.workspace.representation.v1.validate.js +78 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.js +14 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.json +23 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.runtime.json +1733 -0
- package/src/schemas/core/signal/tiinex.signal.v1.schema.source.js +9 -0
- package/src/schemas/core/task/tiinex.task.v1.capabilities.js +11 -0
- package/src/schemas/core/task/tiinex.task.v1.contract.js +3 -0
- package/src/schemas/core/task/tiinex.task.v1.en.i18n.json +15 -0
- package/src/schemas/core/task/tiinex.task.v1.findings.js +18 -0
- package/src/schemas/core/task/tiinex.task.v1.localMaterialization.js +148 -0
- package/src/schemas/core/task/tiinex.task.v1.presenter.js +8 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.js +35 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.json +23 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.runtime.json +1708 -0
- package/src/schemas/core/task/tiinex.task.v1.schema.source.js +9 -0
- package/src/schemas/core/task/tiinex.task.v1.sv.i18n.json +15 -0
- package/src/schemas/core/task/tiinex.task.v1.transitions.js +3 -0
- package/src/schemas/core/task/tiinex.task.v1.validate.js +41 -0
- package/src/schemas/core/topic/tiinex.topic.v1.capabilities.js +14 -0
- package/src/schemas/core/topic/tiinex.topic.v1.creation.js +46 -0
- package/src/schemas/core/topic/tiinex.topic.v1.en.i18n.json +8 -0
- package/src/schemas/core/topic/tiinex.topic.v1.findings.js +11 -0
- package/src/schemas/core/topic/tiinex.topic.v1.localMaterialization.js +135 -0
- package/src/schemas/core/topic/tiinex.topic.v1.presenter.js +1 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.js +34 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.json +23 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.runtime.json +1699 -0
- package/src/schemas/core/topic/tiinex.topic.v1.schema.source.js +9 -0
- package/src/schemas/core/topic/tiinex.topic.v1.sv.i18n.json +8 -0
- package/src/schemas/core/topic/tiinex.topic.v1.transitions.js +31 -0
- package/src/schemas/core/topic/tiinex.topic.v1.validate.js +11 -0
- package/src/schemas/creation.capability.js +289 -0
- package/src/schemas/creation.contracts.js +334 -0
- package/src/schemas/creation.executionSnapshot.js +79 -0
- package/src/schemas/creation.factoryQualification.js +73 -0
- package/src/schemas/creation.renderer.js +244 -0
- package/src/schemas/creation.representation.js +279 -0
- package/src/schemas/creation.rootMetadata.js +6 -0
- package/src/schemas/creation.schemaReferences.js +65 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.js +14 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.json +23 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.runtime.json +1873 -0
- package/src/schemas/discovery/finding/tiinex.discovery.finding.v1.schema.source.js +9 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.js +14 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.json +23 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.runtime.json +1839 -0
- package/src/schemas/discovery/tiinex.discovery.v1.schema.source.js +9 -0
- package/src/schemas/generic.artifact.module.js +25 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.js +26 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.json +23 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.runtime.json +2249 -0
- package/src/schemas/party/organization/tiinex.party.organization.v1.schema.source.js +9 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.js +26 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.json +24 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.runtime.json +2091 -0
- package/src/schemas/party/role/tiinex.party.role.v1.schema.source.js +9 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.capabilities.js +14 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.en.i18n.json +4 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.findings.js +1 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.presenter.js +1 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.js +29 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.json +21 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.runtime.json +2180 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.schema.source.js +9 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.sv.i18n.json +4 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.transitions.js +1 -0
- package/src/schemas/presentation/surface/tiinex.presentation.surface.v1.validate.js +1 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.js +26 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.json +23 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.runtime.json +1733 -0
- package/src/schemas/reduction/tiinex.reduction.v1.schema.source.js +9 -0
- package/src/schemas/reference.shapes.js +33 -0
- package/src/schemas/registry.js +36 -0
- package/src/schemas/resolver.js +13 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.capabilities.js +14 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.en.i18n.json +4 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.findings.js +1 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.presenter.js +1 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.js +29 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.json +21 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.runtime.json +2093 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.schema.source.js +9 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.sv.i18n.json +4 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.transitions.js +1 -0
- package/src/schemas/schema/module/tiinex.schema.module.v1.validate.js +1 -0
- package/src/schemas/schema.factory.descriptor.js +104 -0
- package/src/schemas/schema.githubSourceTarget.js +131 -0
- package/src/schemas/schema.identity.js +10 -0
- package/src/schemas/schema.reference.js +133 -0
- package/src/schemas/schema.source.js +239 -0
- package/src/schemas/tiinex.root.v1.capabilities.js +14 -0
- package/src/schemas/tiinex.root.v1.classify.js +55 -0
- package/src/schemas/tiinex.root.v1.en.i18n.json +24 -0
- package/src/schemas/tiinex.root.v1.fallback.js +84 -0
- package/src/schemas/tiinex.root.v1.findings.js +19 -0
- package/src/schemas/tiinex.root.v1.presenter.js +5 -0
- package/src/schemas/tiinex.root.v1.schema.js +29 -0
- package/src/schemas/tiinex.root.v1.schema.json +24 -0
- package/src/schemas/tiinex.root.v1.schema.runtime.json +1574 -0
- package/src/schemas/tiinex.root.v1.schema.source.js +9 -0
- package/src/schemas/tiinex.root.v1.sv.i18n.json +24 -0
- package/src/schemas/tiinex.root.v1.transitions.js +1 -0
- package/src/schemas/tiinex.root.v1.validate.js +36 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.js +14 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.json +23 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.runtime.json +2027 -0
- package/src/schemas/validation/finding/tiinex.validation.finding.v1.schema.source.js +9 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.js +14 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.json +23 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.runtime.json +1848 -0
- package/src/schemas/validation/method/tiinex.validation.method.v1.schema.source.js +9 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.js +14 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.json +23 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.runtime.json +2015 -0
- package/src/schemas/validation/report/tiinex.validation.report.v1.schema.source.js +9 -0
- package/src/schemas/workspace/tiinex.workspace.v1.capabilities.js +12 -0
- package/src/schemas/workspace/tiinex.workspace.v1.en.i18n.json +7 -0
- package/src/schemas/workspace/tiinex.workspace.v1.findings.js +5 -0
- package/src/schemas/workspace/tiinex.workspace.v1.presenter.js +27 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.js +30 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.json +23 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.runtime.json +1596 -0
- package/src/schemas/workspace/tiinex.workspace.v1.schema.source.js +9 -0
- package/src/schemas/workspace/tiinex.workspace.v1.sv.i18n.json +7 -0
- package/src/schemas/workspace/tiinex.workspace.v1.transitions.js +10 -0
- package/src/schemas/workspace/tiinex.workspace.v1.validate.js +10 -0
- package/src/sources/github/github.issueTarget.js +127 -0
- package/src/sources/origin.references.js +249 -0
- package/src/sources/source.explicitTargets.js +49 -0
- package/src/sources/transport.levels.js +107 -0
- package/src/tooling/portable/adapters/cli/cli.cold-start-input.js +34 -0
- package/src/tooling/portable/adapters/cli/cli.command-input.js +455 -0
- package/src/tooling/portable/adapters/cli/cli.common-author.js +249 -0
- package/src/tooling/portable/adapters/cli/cli.common-output.js +330 -0
- package/src/tooling/portable/adapters/cli/cli.editor-assistance.js +13 -0
- package/src/tooling/portable/adapters/cli/cli.ground-materialize.js +96 -0
- package/src/tooling/portable/adapters/cli/cli.ground-recovery.js +99 -0
- package/src/tooling/portable/adapters/cli/cli.handoff-manufacture.js +345 -0
- package/src/tooling/portable/adapters/cli/cli.handoff-sibling-allocation.js +31 -0
- package/src/tooling/portable/adapters/cli/cli.help.js +80 -0
- package/src/tooling/portable/adapters/cli/cli.land.js +13 -0
- package/src/tooling/portable/adapters/cli/cli.local-output.js +72 -0
- package/src/tooling/portable/adapters/cli/cli.material-policy.js +6 -0
- package/src/tooling/portable/adapters/cli/cli.operator-bridge.js +18 -0
- package/src/tooling/portable/adapters/cli/cli.reduction-input.js +14 -0
- package/src/tooling/portable/adapters/cli/cli.run.js +434 -0
- package/src/tooling/portable/adapters/llm/llm.entrypoint.js +34 -0
- package/src/tooling/portable/adapters/node/checkpoint.verify.js +267 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.bootstrap.js +109 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.enumeration.js +94 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.js +193 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.multiRoot.js +49 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.packageParent.js +130 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.requirements.js +353 -0
- package/src/tooling/portable/adapters/node/handoff.manufacture.scope.js +147 -0
- package/src/tooling/portable/adapters/node/workspaceCarrier.manufacture.js +62 -0
- package/src/tooling/portable/assets/asset.operations.js +170 -0
- package/src/tooling/portable/audit/audit.capability.js +119 -0
- package/src/tooling/portable/bootstrap/artifact.result.selfverify.mjs +109 -0
- package/src/tooling/portable/bootstrap/bootstrap.case.mjs +43 -0
- package/src/tooling/portable/bootstrap/tiinex.llm.bootstrap.md +814 -0
- package/src/tooling/portable/bootstrap/tiinex.llm.bootstrap.pointer.json +25 -0
- package/src/tooling/portable/checkpoint/portable.checkpoint.js +89 -0
- package/src/tooling/portable/conformance/checkpoint.qualification.js +271 -0
- package/src/tooling/portable/draft/draft.create.js +389 -0
- package/src/tooling/portable/draft/draft.crud.js +175 -0
- package/src/tooling/portable/draft/draft.exact.js +173 -0
- package/src/tooling/portable/draft/draft.operations.js +265 -0
- package/src/tooling/portable/draft/draft.qualification.js +45 -0
- package/src/tooling/portable/draft/draft.set.js +193 -0
- package/src/tooling/portable/draft/draft.validation-context.js +7 -0
- package/src/tooling/portable/editor/authoring.parent.js +37 -0
- package/src/tooling/portable/editor/editor.assistance.js +221 -0
- package/src/tooling/portable/editor/staged.validation.js +96 -0
- package/src/tooling/portable/engine.facade.js +468 -0
- package/src/tooling/portable/findings.js +92 -0
- package/src/tooling/portable/grounding/grounding.capsule.js +128 -0
- package/src/tooling/portable/grounding/grounding.continuity.js +283 -0
- package/src/tooling/portable/grounding/grounding.participantAuthority.js +20 -0
- package/src/tooling/portable/grounding/grounding.planningContext.js +34 -0
- package/src/tooling/portable/grounding/grounding.readiness.authority.js +17 -0
- package/src/tooling/portable/grounding/grounding.readiness.js +316 -0
- package/src/tooling/portable/grounding/grounding.readiness.support.js +245 -0
- package/src/tooling/portable/grounding/grounding.sourceEvidence.js +71 -0
- package/src/tooling/portable/grounding/grounding.workContext.js +72 -0
- package/src/tooling/portable/grounding/grounding.workProvenance.js +153 -0
- package/src/tooling/portable/handoff/carrierLineage.js +214 -0
- package/src/tooling/portable/handoff/carrierProfile.js +54 -0
- package/src/tooling/portable/handoff/carrierProjection.js +193 -0
- package/src/tooling/portable/handoff/carrierProjection.routeQualification.js +228 -0
- package/src/tooling/portable/handoff/carrierProjection.shared.js +7 -0
- package/src/tooling/portable/handoff/carrierProjection.workspaces.js +54 -0
- package/src/tooling/portable/handoff/coldConsumerEntrypoint.js +185 -0
- package/src/tooling/portable/handoff/coldStartQualification.contract.js +184 -0
- package/src/tooling/portable/handoff/coldStartQualification.grounding.js +392 -0
- package/src/tooling/portable/handoff/coldStartQualification.js +22 -0
- package/src/tooling/portable/handoff/coldStartQualification.materials.js +364 -0
- package/src/tooling/portable/handoff/coldStartQualification.observation.js +220 -0
- package/src/tooling/portable/handoff/coldStartQualification.run.js +81 -0
- package/src/tooling/portable/handoff/coldStartQualification.shared.js +57 -0
- package/src/tooling/portable/handoff/coldStartRolePointers.js +39 -0
- package/src/tooling/portable/handoff/contextAudit.js +247 -0
- package/src/tooling/portable/handoff/contracts/tiinex.handoff.package.v1.schema.md +409 -0
- package/src/tooling/portable/handoff/handoffAuthoringPlan.js +35 -0
- package/src/tooling/portable/handoff/handoffEndpointProjection.js +61 -0
- package/src/tooling/portable/handoff/handoffLeafProjection.js +91 -0
- package/src/tooling/portable/handoff/humanOutputPresentation.js +21 -0
- package/src/tooling/portable/handoff/manufacture.js +84 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.binding.js +72 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.direct.js +160 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.indexes.js +36 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.js +247 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.projectionProvider.js +44 -0
- package/src/tooling/portable/handoff/materialClosure.archiveV2.workspace.js +226 -0
- package/src/tooling/portable/handoff/materialClosure.descriptor.js +169 -0
- package/src/tooling/portable/handoff/materialClosure.inputBinding.js +372 -0
- package/src/tooling/portable/handoff/materialClosure.inputBinding.support.js +62 -0
- package/src/tooling/portable/handoff/materialClosure.materialized.js +143 -0
- package/src/tooling/portable/handoff/materialClosure.materials.js +116 -0
- package/src/tooling/portable/handoff/materialClosure.package.js +181 -0
- package/src/tooling/portable/handoff/materialClosure.plan.js +204 -0
- package/src/tooling/portable/handoff/materialClosure.readiness.js +36 -0
- package/src/tooling/portable/handoff/materialClosure.requirements.js +137 -0
- package/src/tooling/portable/handoff/operatorContextProjection.js +105 -0
- package/src/tooling/portable/handoff/pointerEntrypoint.js +138 -0
- package/src/tooling/portable/handoff/qualifiedHandoffFixture.js +34 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.build.js +321 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.closure.js +126 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.inspect.js +194 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.materials.js +207 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.projection.js +69 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.roles.js +166 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.routes.js +113 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.shared.js +87 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirst.workspaces.js +160 -0
- package/src/tooling/portable/handoff/recipientV2.artifactFirstPhase1.js +44 -0
- package/src/tooling/portable/handoff/recipientV2.artifactInspection.js +55 -0
- package/src/tooling/portable/handoff/recipientV2.artifacts.js +174 -0
- package/src/tooling/portable/handoff/recipientV2.coldProjection.js +24 -0
- package/src/tooling/portable/handoff/recipientV2.delivery.js +48 -0
- package/src/tooling/portable/handoff/recipientV2.endpointRolePointers.js +179 -0
- package/src/tooling/portable/handoff/recipientV2.entryContract.js +28 -0
- package/src/tooling/portable/handoff/recipientV2.humanOutput.js +78 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.helpers.js +218 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.js +194 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.pathToken.js +9 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.projection.js +58 -0
- package/src/tooling/portable/handoff/recipientV2.inspect.workspaces.js +177 -0
- package/src/tooling/portable/handoff/recipientV2.lineage.js +142 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.build.js +147 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.constants.js +4 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.contract.js +101 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.inspect.helpers.js +126 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.inspect.js +185 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.js +12 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.shared.js +24 -0
- package/src/tooling/portable/handoff/recipientV2.packageV1.workspaceProjection.js +22 -0
- package/src/tooling/portable/handoff/recipientV2.pointer.js +40 -0
- package/src/tooling/portable/handoff/recipientV2.routeSelection.js +16 -0
- package/src/tooling/portable/handoff/recipientV2.topology.helpers.js +20 -0
- package/src/tooling/portable/handoff/recipientV2.topology.js +320 -0
- package/src/tooling/portable/handoff/recipientV2.topology.materials.js +70 -0
- package/src/tooling/portable/handoff/recipientV2.topology.workspaces.js +193 -0
- package/src/tooling/portable/handoff/recipientV2.transportManifest.js +123 -0
- package/src/tooling/portable/handoff/recipientV2.workspaceRepresentation.js +163 -0
- package/src/tooling/portable/handoff/routeArtifactConformance.js +130 -0
- package/src/tooling/portable/handoff/toolingBootstrap.js +67 -0
- package/src/tooling/portable/handoff/transportCompanion.js +175 -0
- package/src/tooling/portable/handoff/workspaceByteProvider.archive.js +95 -0
- package/src/tooling/portable/handoff/workspaceByteProvider.js +271 -0
- package/src/tooling/portable/handoff/workspaceCarrier.manufacture.js +93 -0
- package/src/tooling/portable/handoff/workspaceLandingPlan.js +142 -0
- package/src/tooling/portable/handoff/workspacePackageSources.js +105 -0
- package/src/tooling/portable/handoff/workspaceQualifiedReference.js +10 -0
- package/src/tooling/portable/handoff/workspaceSourceIdentity.js +52 -0
- package/src/tooling/portable/handoff/workspaceTargetConformance.js +134 -0
- package/src/tooling/portable/host/host.capabilities.js +181 -0
- package/src/tooling/portable/host/tool.bindings.js +357 -0
- package/src/tooling/portable/host/tool.receiptNormalization.js +141 -0
- package/src/tooling/portable/index.js +52 -0
- package/src/tooling/portable/input/node.input.js +184 -0
- package/src/tooling/portable/input/portable.input.js +249 -0
- package/src/tooling/portable/lifecycle/lifecycle.action.js +11 -0
- package/src/tooling/portable/lifecycle/lifecycle.material.js +173 -0
- package/src/tooling/portable/lifecycle/lifecycle.operations.js +34 -0
- package/src/tooling/portable/lifecycle/lifecycle.readiness.js +247 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.audit.js +22 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.evidence.js +36 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.js +306 -0
- package/src/tooling/portable/lineage/lineage.integrity.apply.structure.js +178 -0
- package/src/tooling/portable/lineage/lineage.integrity.plan.js +377 -0
- package/src/tooling/portable/lineage/lineage.integrity.projection.human.js +82 -0
- package/src/tooling/portable/lineage/lineage.integrity.projection.js +349 -0
- package/src/tooling/portable/lineage/lineage.operations.js +32 -0
- package/src/tooling/portable/lineage/lineage.print.js +398 -0
- package/src/tooling/portable/lineage/lineage.print.render.js +88 -0
- package/src/tooling/portable/lineage/lineage.print.utils.js +58 -0
- package/src/tooling/portable/lineage/lineage.publicationProviderReceipts.js +141 -0
- package/src/tooling/portable/lineage/lineage.publicationQualification.js +183 -0
- package/src/tooling/portable/lineage/lineage.search.js +301 -0
- package/src/tooling/portable/live/live.artifact.js +192 -0
- package/src/tooling/portable/live/live.export.js +107 -0
- package/src/tooling/portable/live/live.lineage.closure.js +71 -0
- package/src/tooling/portable/live/live.lineage.js +338 -0
- package/src/tooling/portable/live/live.protocol.js +181 -0
- package/src/tooling/portable/materialization/durable.materialize.js +162 -0
- package/src/tooling/portable/materialization/epistemic.plan.js +239 -0
- package/src/tooling/portable/materialization/loaded.parent.js +54 -0
- package/src/tooling/portable/materialization/materialization.facade.js +30 -0
- package/src/tooling/portable/operation.catalog.js +393 -0
- package/src/tooling/portable/operation.catalog.package.js +183 -0
- package/src/tooling/portable/operation.result.js +25 -0
- package/src/tooling/portable/orchestration/task.prepare.js +191 -0
- package/src/tooling/portable/output/artifact.result.package.js +308 -0
- package/src/tooling/portable/output/deterministic.zip.js +88 -0
- package/src/tooling/portable/output/node.artifact-set.js +223 -0
- package/src/tooling/portable/output/node.draft.js +41 -0
- package/src/tooling/portable/output/node.zip.js +39 -0
- package/src/tooling/portable/output/recipientV2.zip.js +59 -0
- package/src/tooling/portable/overview/blockingCue.js +16 -0
- package/src/tooling/portable/overview/operatingOverview.js +413 -0
- package/src/tooling/portable/package/generation.binding.js +314 -0
- package/src/tooling/portable/package/generation.binding.projection.js +128 -0
- package/src/tooling/portable/package/material.graph.js +236 -0
- package/src/tooling/portable/package/runtime.package.js +321 -0
- package/src/tooling/portable/package/schema.transition.companion.js +196 -0
- package/src/tooling/portable/package/semantic.package.graph.js +272 -0
- package/src/tooling/portable/package/semantic.package.js +203 -0
- package/src/tooling/portable/package/semantic.package.schema-resolution.js +158 -0
- package/src/tooling/portable/package/semantic.package.transition-registry.js +189 -0
- package/src/tooling/portable/package/semantic.package.types.js +18 -0
- package/src/tooling/portable/providers/schema.bootstrap.provenance.js +10 -0
- package/src/tooling/portable/providers/schema.provider.qualification.js +52 -0
- package/src/tooling/portable/providers/schema.providers.js +458 -0
- package/src/tooling/portable/publication/runtime.publication.js +53 -0
- package/src/tooling/portable/qualification.js +150 -0
- package/src/tooling/portable/reduction/reduction.composition.js +229 -0
- package/src/tooling/portable/reduction/reduction.eligibility.helpers.js +258 -0
- package/src/tooling/portable/reduction/reduction.eligibility.js +191 -0
- package/src/tooling/portable/reduction/reduction.operations.js +30 -0
- package/src/tooling/portable/reduction/reduction.preflight.js +85 -0
- package/src/tooling/portable/reduction/reduction.shared.js +173 -0
- package/src/tooling/portable/schema/bootstrap/canonical.pack.js +24 -0
- package/src/tooling/portable/schema/bootstrap/docs-3988951208eb9a8926e84ab42625d4b42fa00c2d/party/role/tiinex.party.role.v1.schema.md +289 -0
- package/src/tooling/portable/schema/bootstrap/docs-3988951208eb9a8926e84ab42625d4b42fa00c2d/validation/report/tiinex.validation.report.v1.schema.md +300 -0
- package/src/tooling/portable/schema/bootstrap/qualified-local-root/tiinex.root.v1.runtime-projection.json +48 -0
- package/src/tooling/portable/schema/bootstrap/qualified-local-root/tiinex.root.v1.schema.md +865 -0
- package/src/tooling/portable/schema/contract.compile.js +406 -0
- package/src/tooling/portable/schema/contract.compile.utils.js +9 -0
- package/src/tooling/portable/schema/contract.constraints.js +117 -0
- package/src/tooling/portable/schema/contract.envelope.validate.js +177 -0
- package/src/tooling/portable/schema/contract.field-domain.compile.js +399 -0
- package/src/tooling/portable/schema/contract.field-domain.js +247 -0
- package/src/tooling/portable/schema/contract.field-shape.compile.js +34 -0
- package/src/tooling/portable/schema/contract.inheritance.inline.js +103 -0
- package/src/tooling/portable/schema/contract.inheritance.js +210 -0
- package/src/tooling/portable/schema/contract.inheritance.record.js +76 -0
- package/src/tooling/portable/schema/contract.machine-shape.js +309 -0
- package/src/tooling/portable/schema/contract.project.js +81 -0
- package/src/tooling/portable/schema/contract.semantic-resolution.js +82 -0
- package/src/tooling/portable/schema/contract.validate.js +0 -0
- package/src/tooling/portable/schema/lexical.shape.v1.js +338 -0
- package/src/tooling/portable/schema/llm.companion.js +108 -0
- package/src/tooling/portable/schema/named.declarations.js +162 -0
- package/src/tooling/portable/schema/ordinary.contract.js +193 -0
- package/src/tooling/portable/schema/ordinary.fields.js +205 -0
- package/src/tooling/portable/schema/qualifiedLocalRoot.projection.js +70 -0
- package/src/tooling/portable/schema/qualifiedLocalRoot.runtime.js +170 -0
- package/src/tooling/portable/schema/schema.contract.js +465 -0
- package/src/tooling/portable/schema/schema.guide.js +326 -0
- package/src/tooling/portable/schema/schema.snapshot.js +119 -0
- package/src/tooling/portable/session/portable.session.js +145 -0
- package/src/tooling/portable/transfer/transfer.plan.js +102 -0
- package/src/transitions/record.transitions.js +484 -0
- package/src/transitions/transition.validate.js +129 -0
- package/src/validation/findings.js +76 -0
- package/src/validation/validateArtifact.js +216 -0
- package/src/workspaces/workspace.entrypointCapability.js +44 -0
- package/src/workspaces/workspace.materialRole.js +242 -0
- package/src/workspaces/workspace.recordPaths.js +426 -0
- package/tools/tiinex-portable.mjs +6 -0
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { externalWebArtifactUrl, normalizeExternalWebArtifactUrl } from '../sources/source.explicitTargets.js';
|
|
2
|
+
|
|
3
|
+
const EXACT_GITHUB_COMMIT = /^[0-9a-f]{40}$/i;
|
|
4
|
+
|
|
5
|
+
export function projectPackageSourceReference(material = {}, options = {}) {
|
|
6
|
+
const source = material.source || options.source || {};
|
|
7
|
+
const sourceTarget = material.sourceTarget || options.sourceTarget || {};
|
|
8
|
+
const adapterId = String(source.adapterId || options.adapterId || '').trim();
|
|
9
|
+
const repo = String(source.repo || source.repository || source.config?.repo || options.repo || '').trim();
|
|
10
|
+
const configuredRef = String(source.ref || source.config?.ref || source.resolvedRef || options.ref || '').trim();
|
|
11
|
+
const materializedCommit = exactCommit(sourceTarget.materializedCommit || source.materializedCommit || source.commit || options.materializedCommit);
|
|
12
|
+
const inputTarget = exactInputTarget(material, sourceTarget, adapterId);
|
|
13
|
+
const sourceArtifactPath = String(sourceTarget.sourceArtifactPath || options.sourceArtifactPath || (sourceTarget.surface === 'repoFiles' ? material.path || '' : '')).trim();
|
|
14
|
+
const path = sourceArtifactPath || String(options.path || material.path || '').trim();
|
|
15
|
+
const targetKind = String(sourceTarget.targetKind || source.sourceKind || options.targetKind || '').trim();
|
|
16
|
+
const surface = String(sourceTarget.surface || options.surface || '').trim();
|
|
17
|
+
const rawUrl = normalizeExternalWebArtifactUrl(sourceTarget.rawUrl || source.url || options.rawUrl || '');
|
|
18
|
+
const refKind = materializedCommit ? 'immutable-commit' : configuredRef ? 'mutable-or-unqualified-ref' : 'unpinned';
|
|
19
|
+
const githubTargetReady = adapterId === 'github' && Boolean(repo) && Boolean(path || inputTarget);
|
|
20
|
+
const externalTargetReady = adapterId !== 'github' && Boolean(inputTarget);
|
|
21
|
+
const exactTarget = githubTargetReady || externalTargetReady;
|
|
22
|
+
const status = adapterId === 'github'
|
|
23
|
+
? (githubTargetReady && materializedCommit ? 'pinned-reference' : 'degraded-reference')
|
|
24
|
+
: (externalTargetReady ? 'exact-target-reference' : 'degraded-reference');
|
|
25
|
+
|
|
26
|
+
return deepFreeze({
|
|
27
|
+
schema: 'tiinex.export.package.source-target.v2',
|
|
28
|
+
adapterId,
|
|
29
|
+
status,
|
|
30
|
+
exactTarget,
|
|
31
|
+
immutability: materializedCommit ? 'immutable-materialized-commit' : (exactTarget ? 'target-exact-content-not-immutable' : 'degraded'),
|
|
32
|
+
repo,
|
|
33
|
+
configuredRef,
|
|
34
|
+
materializedCommit,
|
|
35
|
+
ref: materializedCommit || configuredRef,
|
|
36
|
+
refKind,
|
|
37
|
+
path,
|
|
38
|
+
sourceArtifactPath,
|
|
39
|
+
surface,
|
|
40
|
+
targetKind,
|
|
41
|
+
inputTarget,
|
|
42
|
+
rawUrl,
|
|
43
|
+
sourceId: String(source.id || ''),
|
|
44
|
+
sourceKind: String(source.sourceKind || source.kind || ''),
|
|
45
|
+
boundary: String(source.boundary || material.importBoundary || options.boundary || ''),
|
|
46
|
+
unavailable: Boolean(options.unavailable || material.previewState === 'metadata-only' || material.previewState === 'omitted-large')
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function isExactGithubCommit(value = '') {
|
|
51
|
+
return EXACT_GITHUB_COMMIT.test(String(value || '').trim());
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export function sourceReferencePackageStatus(target = {}) {
|
|
55
|
+
if (target.adapterId === 'github') return target.materializedCommit && target.repo && (target.path || target.inputTarget) ? 'pinned-reference' : 'degraded-reference';
|
|
56
|
+
return target.inputTarget ? 'exact-target-reference' : 'degraded-reference';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function exactCommit(value = '') {
|
|
60
|
+
const text = String(value || '').trim();
|
|
61
|
+
return EXACT_GITHUB_COMMIT.test(text) ? text.toLowerCase() : '';
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function exactInputTarget(material = {}, target = {}, adapterId = '') {
|
|
65
|
+
const explicit = String(target.inputTarget || '').trim();
|
|
66
|
+
if (explicit) {
|
|
67
|
+
if (adapterId === 'github') return explicit;
|
|
68
|
+
return normalizeExternalWebArtifactUrl(explicit) || explicit;
|
|
69
|
+
}
|
|
70
|
+
const external = externalWebArtifactUrl(material);
|
|
71
|
+
if (external) return external;
|
|
72
|
+
const permalink = String(material.source?.permalink || material.source?.config?.permalink || '').trim();
|
|
73
|
+
return permalink;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function deepFreeze(value) {
|
|
77
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
|
|
78
|
+
if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) return value;
|
|
79
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
80
|
+
return Object.freeze(value);
|
|
81
|
+
}
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { projectPackageSourceReference } from './package.sourceReference.js';
|
|
2
|
+
import { schemaIdForRecord } from '../schemas/schema.identity.js';
|
|
3
|
+
|
|
4
|
+
export const EXPORT_WORKSPACE_CONTEXT_SCHEMA_ID = 'tiinex.export.package.workspace-context.v1';
|
|
5
|
+
|
|
6
|
+
export function buildExportWorkspaceContext(workspace = {}, input = {}) {
|
|
7
|
+
const records = Array.isArray(input.records) ? input.records : (Array.isArray(workspace.records) ? workspace.records : []);
|
|
8
|
+
const assets = Array.isArray(input.assets) ? input.assets : (Array.isArray(workspace.assets) ? workspace.assets : []);
|
|
9
|
+
const workspaceArtifacts = records.filter(isWorkspaceArtifactRecord).map(workspaceArtifactDescriptor);
|
|
10
|
+
const workspaceImport = sanitizeWorkspaceImport(workspace.workspaceImport || {});
|
|
11
|
+
const localWorkspaceMarkdown = localOwnedWorkspaceMarkdown(workspace, workspaceImport);
|
|
12
|
+
const sources = (Array.isArray(workspace.sources) ? workspace.sources : []).map(sourceDescriptor);
|
|
13
|
+
const sourceOrder = (Array.isArray(workspace.sourceOrder) ? workspace.sourceOrder : []).map(String);
|
|
14
|
+
const memberBindings = (Array.isArray(workspace.workspaceMemberBindings) ? workspace.workspaceMemberBindings : []).map(sanitizeMemberBinding).filter(Boolean);
|
|
15
|
+
const materialMembership = Object.freeze({
|
|
16
|
+
recordIds: Object.freeze(records.map((record) => String(record.id || record.path || '')).filter(Boolean)),
|
|
17
|
+
assetIds: Object.freeze(assets.map((asset) => String(asset.id || asset.path || '')).filter(Boolean)),
|
|
18
|
+
workspaceArtifactIds: Object.freeze(workspaceArtifacts.map((artifact) => artifact.id).filter(Boolean))
|
|
19
|
+
});
|
|
20
|
+
const markdownPackagePath = localWorkspaceMarkdown ? 'context/workspace.workspace.md' : '';
|
|
21
|
+
return deepFreeze({
|
|
22
|
+
schema: EXPORT_WORKSPACE_CONTEXT_SCHEMA_ID,
|
|
23
|
+
id: String(workspace.id || ''),
|
|
24
|
+
name: String(workspace.name || workspace.title || 'Workspace'),
|
|
25
|
+
title: String(workspace.title || workspace.name || 'Workspace'),
|
|
26
|
+
createdAt: String(workspace.createdAt || ''),
|
|
27
|
+
kind: String(workspace.kind || 'workspace'),
|
|
28
|
+
mode: String(workspace.mode || 'feed'),
|
|
29
|
+
workspaceImport,
|
|
30
|
+
workspaceMarkdown: Object.freeze({
|
|
31
|
+
ownership: localWorkspaceMarkdown ? 'owned-local' : (workspace.workspaceMarkdown ? 'reference-only-or-unqualified' : 'absent'),
|
|
32
|
+
available: Boolean(localWorkspaceMarkdown),
|
|
33
|
+
packagePath: markdownPackagePath,
|
|
34
|
+
bytes: new TextEncoder().encode(localWorkspaceMarkdown).byteLength
|
|
35
|
+
}),
|
|
36
|
+
sources: Object.freeze(sources),
|
|
37
|
+
sourceOrder: Object.freeze(sourceOrder),
|
|
38
|
+
workspaceArtifacts: Object.freeze(workspaceArtifacts),
|
|
39
|
+
workspaceMemberBindings: Object.freeze(memberBindings),
|
|
40
|
+
materialMembership,
|
|
41
|
+
boundary: 'Canonical workspace context projection for handoff/re-ingest. It preserves workspace/source configuration truth without turning source references into local leaves or making directory placement semantic identity.'
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function workspaceContextOwnedMarkdown(workspace = {}) {
|
|
46
|
+
const workspaceImport = sanitizeWorkspaceImport(workspace.workspaceImport || {});
|
|
47
|
+
return localOwnedWorkspaceMarkdown(workspace, workspaceImport);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function localOwnedWorkspaceMarkdown(workspace = {}, workspaceImport = {}) {
|
|
51
|
+
const markdown = String(workspace.workspaceMarkdown || '');
|
|
52
|
+
if (!markdown) return '';
|
|
53
|
+
const mode = String(workspaceImport.sourceMode || workspace.sourceMode || '').trim().toLowerCase();
|
|
54
|
+
const boundary = String(workspaceImport.boundary || workspace.source?.boundary || '').trim().toLowerCase();
|
|
55
|
+
const localOwned = mode.startsWith('local') || mode.startsWith('manual') || mode.startsWith('package-import') || boundary.includes('browser-local') || workspaceImport.localDraft === true;
|
|
56
|
+
return localOwned ? markdown : '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function isWorkspaceArtifactRecord(record = {}) {
|
|
60
|
+
return Boolean(record.workspaceArtifactRole?.openEligible || record.workspaceArtifactRole?.mergeEligible)
|
|
61
|
+
|| schemaIdForRecord(record) === 'tiinex.workspace.v1'
|
|
62
|
+
|| /\.workspace\.md$/i.test(String(record.sourceTarget?.sourceArtifactPath || record.path || ''));
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function workspaceArtifactDescriptor(record = {}) {
|
|
66
|
+
const sourceTarget = projectPackageSourceReference(record);
|
|
67
|
+
return deepFreeze({
|
|
68
|
+
id: String(record.id || record.path || ''),
|
|
69
|
+
title: String(record.title || record.path || 'Workspace artifact'),
|
|
70
|
+
path: String(record.path || ''),
|
|
71
|
+
schemaId: schemaIdForRecord(record),
|
|
72
|
+
sourceMode: String(record.sourceMode || ''),
|
|
73
|
+
sourceReference: sourceTarget,
|
|
74
|
+
openEligible: record.workspaceArtifactRole?.openEligible !== false,
|
|
75
|
+
mergeEligible: record.workspaceArtifactRole?.mergeEligible !== false
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function sourceDescriptor(source = {}) {
|
|
80
|
+
const projection = projectPackageSourceReference({ source, sourceTarget: {} }, { unavailable: false });
|
|
81
|
+
return deepFreeze({
|
|
82
|
+
id: String(source.id || ''),
|
|
83
|
+
label: String(source.label || ''),
|
|
84
|
+
adapterId: String(source.adapterId || ''),
|
|
85
|
+
sourceKind: String(source.sourceKind || source.kind || ''),
|
|
86
|
+
repo: String(source.repo || source.config?.repo || ''),
|
|
87
|
+
ref: String(source.ref || source.config?.ref || ''),
|
|
88
|
+
requestedRef: String(source.requestedRef ?? source.config?.requestedRef ?? ''),
|
|
89
|
+
materializedCommit: String(source.materializedCommit || ''),
|
|
90
|
+
rootPath: String(source.rootPath || source.config?.rootPath || ''),
|
|
91
|
+
boundary: String(source.boundary || ''),
|
|
92
|
+
repoDiscovery: Boolean(source.repoDiscovery),
|
|
93
|
+
issueDiscovery: Boolean(source.issueDiscovery),
|
|
94
|
+
issueUrls: String(source.issueUrls || source.config?.issueUrls || ''),
|
|
95
|
+
explicitFileRefs: Object.freeze(Array.isArray(source.explicitFileRefs) ? source.explicitFileRefs.map(String) : []),
|
|
96
|
+
exactReference: projection
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function sanitizeWorkspaceImport(value = {}) {
|
|
101
|
+
return deepFreeze({
|
|
102
|
+
schema: String(value.schema || 'tiinex.workspace.import.v1'),
|
|
103
|
+
path: String(value.path || ''),
|
|
104
|
+
sourceMode: String(value.sourceMode || ''),
|
|
105
|
+
boundary: String(value.boundary || ''),
|
|
106
|
+
openedFromWorkspaceId: String(value.openedFromWorkspaceId || ''),
|
|
107
|
+
contextReferenceId: String(value.contextReferenceId || ''),
|
|
108
|
+
localDraft: value.localDraft === true
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function sanitizeMemberBinding(binding = {}) {
|
|
113
|
+
const descriptor = binding.descriptorTarget || {};
|
|
114
|
+
const identity = binding.memberIdentity || {};
|
|
115
|
+
if (!descriptor.externalTarget || !identity.key) return null;
|
|
116
|
+
return deepFreeze({
|
|
117
|
+
schema: String(binding.schema || 'tiinex.workspace.memberBinding.v1'),
|
|
118
|
+
descriptorTarget: {
|
|
119
|
+
schema: String(descriptor.schema || 'tiinex.publicTarget.v1'),
|
|
120
|
+
adapterId: String(descriptor.adapterId || ''),
|
|
121
|
+
targetKind: String(descriptor.targetKind || 'workspace'),
|
|
122
|
+
externalTarget: String(descriptor.externalTarget || ''),
|
|
123
|
+
repository: String(descriptor.repository || ''),
|
|
124
|
+
ref: String(descriptor.ref || ''),
|
|
125
|
+
path: String(descriptor.path || '')
|
|
126
|
+
},
|
|
127
|
+
memberIdentity: {
|
|
128
|
+
schema: String(identity.schema || 'tiinex.workspace.memberIdentity.v1'),
|
|
129
|
+
kind: String(identity.kind || 'semantic'),
|
|
130
|
+
key: String(identity.key || ''),
|
|
131
|
+
name: String(identity.name || ''),
|
|
132
|
+
label: String(identity.label || ''),
|
|
133
|
+
sourceKind: String(identity.sourceKind || ''),
|
|
134
|
+
sourceSignature: String(identity.sourceSignature || '')
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function deepFreeze(value) {
|
|
140
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
|
|
141
|
+
if (ArrayBuffer.isView(value) || value instanceof ArrayBuffer) return value;
|
|
142
|
+
for (const child of Object.values(value)) deepFreeze(child);
|
|
143
|
+
return Object.freeze(value);
|
|
144
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { inspectExportPackageBundle } from './package.builder.js';
|
|
2
|
+
import { packageFileByteView, packageFileBytes } from './package.bytes.js';
|
|
3
|
+
import { inspectTreeExportBundle } from './tree.bundle.js';
|
|
4
|
+
|
|
5
|
+
export function exportPackageZipUint8Array(bundle = {}) {
|
|
6
|
+
const inspection = inspectExportPackageBundle(bundle);
|
|
7
|
+
if (inspection.status !== 'valid') throw new Error('export.package.zip.bundle.invalid');
|
|
8
|
+
return exportFileMapZipUint8Array(bundle.files || [], 'export.package.zip.path.invalid');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function exportTreeZipUint8Array(bundle = {}) {
|
|
12
|
+
const inspection = inspectTreeExportBundle(bundle);
|
|
13
|
+
if (inspection.status === 'invalid') throw new Error('export.tree.zip.bundle.invalid');
|
|
14
|
+
return exportFileMapZipUint8Array(bundle.files || [], 'export.tree.zip.path.invalid');
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function exportFileMapZipUint8Array(files = [], invalidPathError = 'export.zip.path.invalid') {
|
|
18
|
+
const entries = (files || []).map((file) => ({ name: safeZipPath(file.path), data: packageFileByteView(file) }));
|
|
19
|
+
if (entries.some((entry) => !entry.name)) throw new Error(invalidPathError);
|
|
20
|
+
return storedZip(entries);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export function exportPackageZipBlob(bundle = {}) {
|
|
24
|
+
const bytes = exportPackageZipUint8Array(bundle);
|
|
25
|
+
return new Blob([bytes], { type: 'application/zip' });
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export function exportTreeZipBlob(bundle = {}) {
|
|
29
|
+
const bytes = exportTreeZipUint8Array(bundle);
|
|
30
|
+
return new Blob([bytes], { type: 'application/zip' });
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function storedZip(entries) {
|
|
34
|
+
const localParts = [];
|
|
35
|
+
const centralParts = [];
|
|
36
|
+
let offset = 0;
|
|
37
|
+
for (const entry of entries) {
|
|
38
|
+
const name = utf8(entry.name);
|
|
39
|
+
const data = entry.data instanceof Uint8Array ? entry.data : utf8(String(entry.data || ''));
|
|
40
|
+
const crc = crc32(data);
|
|
41
|
+
const local = new Uint8Array(30 + name.length);
|
|
42
|
+
const view = new DataView(local.buffer);
|
|
43
|
+
view.setUint32(0, 0x04034b50, true);
|
|
44
|
+
view.setUint16(4, 20, true);
|
|
45
|
+
view.setUint16(6, 0x0800, true);
|
|
46
|
+
view.setUint16(8, 0, true);
|
|
47
|
+
view.setUint16(10, 0, true);
|
|
48
|
+
view.setUint16(12, 0x0021, true); // 1980-01-01, aligned with portable deterministic ZIP output.
|
|
49
|
+
view.setUint32(14, crc, true);
|
|
50
|
+
view.setUint32(18, data.length, true);
|
|
51
|
+
view.setUint32(22, data.length, true);
|
|
52
|
+
view.setUint16(26, name.length, true);
|
|
53
|
+
view.setUint16(28, 0, true);
|
|
54
|
+
local.set(name, 30);
|
|
55
|
+
localParts.push(local, data);
|
|
56
|
+
|
|
57
|
+
const central = new Uint8Array(46 + name.length);
|
|
58
|
+
const cv = new DataView(central.buffer);
|
|
59
|
+
cv.setUint32(0, 0x02014b50, true);
|
|
60
|
+
cv.setUint16(4, 20, true);
|
|
61
|
+
cv.setUint16(6, 20, true);
|
|
62
|
+
cv.setUint16(8, 0x0800, true);
|
|
63
|
+
cv.setUint16(10, 0, true);
|
|
64
|
+
cv.setUint16(12, 0, true);
|
|
65
|
+
cv.setUint16(14, 0x0021, true);
|
|
66
|
+
cv.setUint32(16, crc, true);
|
|
67
|
+
cv.setUint32(20, data.length, true);
|
|
68
|
+
cv.setUint32(24, data.length, true);
|
|
69
|
+
cv.setUint16(28, name.length, true);
|
|
70
|
+
cv.setUint16(30, 0, true);
|
|
71
|
+
cv.setUint16(32, 0, true);
|
|
72
|
+
cv.setUint16(34, 0, true);
|
|
73
|
+
cv.setUint16(36, 0, true);
|
|
74
|
+
cv.setUint32(38, 0, true);
|
|
75
|
+
cv.setUint32(42, offset, true);
|
|
76
|
+
central.set(name, 46);
|
|
77
|
+
centralParts.push(central);
|
|
78
|
+
offset += local.length + data.length;
|
|
79
|
+
}
|
|
80
|
+
const centralDirectory = concat(centralParts);
|
|
81
|
+
const end = new Uint8Array(22);
|
|
82
|
+
const ev = new DataView(end.buffer);
|
|
83
|
+
ev.setUint32(0, 0x06054b50, true);
|
|
84
|
+
ev.setUint16(4, 0, true);
|
|
85
|
+
ev.setUint16(6, 0, true);
|
|
86
|
+
ev.setUint16(8, entries.length, true);
|
|
87
|
+
ev.setUint16(10, entries.length, true);
|
|
88
|
+
ev.setUint32(12, centralDirectory.length, true);
|
|
89
|
+
ev.setUint32(16, offset, true);
|
|
90
|
+
ev.setUint16(20, 0, true);
|
|
91
|
+
return concat([...localParts, centralDirectory, end]);
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function safeZipPath(value = '') {
|
|
95
|
+
const input = String(value || '').replace(/\\/g, '/').replace(/^\/+/, '');
|
|
96
|
+
const parts = [];
|
|
97
|
+
for (const part of input.split('/')) {
|
|
98
|
+
if (!part || part === '.') continue;
|
|
99
|
+
if (part === '..') return '';
|
|
100
|
+
parts.push(part.replace(/[\u0000-\u001f<>:"|?*]/g, '_'));
|
|
101
|
+
}
|
|
102
|
+
return parts.join('/');
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function utf8(value = '') { return new TextEncoder().encode(String(value || '')); }
|
|
106
|
+
function concat(parts = []) {
|
|
107
|
+
const total = parts.reduce((sum, part) => sum + part.length, 0);
|
|
108
|
+
const out = new Uint8Array(total);
|
|
109
|
+
let offset = 0;
|
|
110
|
+
for (const part of parts) { out.set(part, offset); offset += part.length; }
|
|
111
|
+
return out;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const CRC_TABLE = makeCrcTable();
|
|
115
|
+
function crc32(buffer) {
|
|
116
|
+
let crc = 0xffffffff;
|
|
117
|
+
for (const byte of buffer) crc = CRC_TABLE[(crc ^ byte) & 0xff] ^ (crc >>> 8);
|
|
118
|
+
return (crc ^ 0xffffffff) >>> 0;
|
|
119
|
+
}
|
|
120
|
+
function makeCrcTable() {
|
|
121
|
+
const table = new Uint32Array(256);
|
|
122
|
+
for (let index = 0; index < 256; index += 1) {
|
|
123
|
+
let value = index;
|
|
124
|
+
for (let bit = 0; bit < 8; bit += 1) value = (value & 1) ? (0xedb88320 ^ (value >>> 1)) : (value >>> 1);
|
|
125
|
+
table[index] = value >>> 0;
|
|
126
|
+
}
|
|
127
|
+
return table;
|
|
128
|
+
}
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
import { buildRecordLogicalPathMap, recordLogicalPathFromMap } from '../workspaces/workspace.recordPaths.js';
|
|
2
|
+
import { resolveTransportPlan } from '../sources/transport.levels.js';
|
|
3
|
+
import { isWorkspaceRecord } from '../actions/record.actions.js';
|
|
4
|
+
export const TREE_EXPORT_BUNDLE_SCHEMA_ID = 'tiinex.export.tree.bundle.v1';
|
|
5
|
+
|
|
6
|
+
export function buildWorkspaceTreeExportBundle(workspace = {}, input = {}) {
|
|
7
|
+
const records = Array.isArray(input.records) ? input.records : (Array.isArray(workspace.records) ? workspace.records : []);
|
|
8
|
+
const assets = Array.isArray(input.assets) ? input.assets : (Array.isArray(workspace.assets) ? workspace.assets : []);
|
|
9
|
+
const includeAssets = input.includeAssets !== false;
|
|
10
|
+
const includeWorkspaceEntries = input.includeWorkspaceEntries !== false;
|
|
11
|
+
const builtAt = typeof input.clock === 'function' ? input.clock() : (input.builtAt || new Date().toISOString());
|
|
12
|
+
const transport = resolveTransportPlan(input.sourceConfig || workspace.sourceConfig || {}, 'local-download', { defaultLevel: 'TL0', allowFallback: false });
|
|
13
|
+
const findings = [];
|
|
14
|
+
const files = [];
|
|
15
|
+
const recordPathMap = buildRecordLogicalPathMap(records);
|
|
16
|
+
|
|
17
|
+
if (includeWorkspaceEntries) {
|
|
18
|
+
for (const entry of collectWorkspaceTreeEntries(workspace, input, records)) {
|
|
19
|
+
const file = treeFileForWorkspaceEntry(entry, findings);
|
|
20
|
+
if (file) files.push(file);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
for (const record of records) {
|
|
25
|
+
if (isWorkspaceRecord(record)) continue;
|
|
26
|
+
const file = treeFileForRecord(record, findings, recordPathMap);
|
|
27
|
+
if (file) files.push(file);
|
|
28
|
+
}
|
|
29
|
+
if (includeAssets) {
|
|
30
|
+
for (const asset of assets) {
|
|
31
|
+
const file = treeFileForAsset(asset, findings);
|
|
32
|
+
if (file) files.push(file);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
const unique = uniqueFiles(files, findings);
|
|
37
|
+
const counts = Object.freeze({
|
|
38
|
+
files: unique.length,
|
|
39
|
+
records: unique.filter((file) => file.kind === 'artifact-markdown').length,
|
|
40
|
+
workspaceEntries: unique.filter((file) => file.kind === 'workspace-markdown').length,
|
|
41
|
+
assets: unique.filter((file) => file.kind === 'asset-content').length,
|
|
42
|
+
skippedRecords: findings.filter((finding) => finding.code === 'export.tree.record.content-missing').length,
|
|
43
|
+
skippedAssets: findings.filter((finding) => finding.code === 'export.tree.asset.content-unavailable').length,
|
|
44
|
+
warnings: findings.filter((finding) => finding.severity === 'warning').length,
|
|
45
|
+
errors: findings.filter((finding) => finding.severity === 'error').length,
|
|
46
|
+
findings: findings.length
|
|
47
|
+
});
|
|
48
|
+
const status = counts.errors ? 'blocked' : counts.warnings ? 'degraded' : 'ready';
|
|
49
|
+
|
|
50
|
+
return deepFreeze({
|
|
51
|
+
schema: TREE_EXPORT_BUNDLE_SCHEMA_ID,
|
|
52
|
+
exportType: 'tree',
|
|
53
|
+
transportLevel: transport.selectedLevel,
|
|
54
|
+
builtAt,
|
|
55
|
+
status,
|
|
56
|
+
boundary: 'Ordinary local download tree export. File paths mirror the logical Tiinex tree; no package envelope, receipts, source mutation, remote fetch, or provenance inference is included.',
|
|
57
|
+
packageEnvelope: false,
|
|
58
|
+
sourceMutation: false,
|
|
59
|
+
remoteFetch: false,
|
|
60
|
+
transport,
|
|
61
|
+
counts,
|
|
62
|
+
files: unique,
|
|
63
|
+
findings
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export function inspectTreeExportBundle(bundle = {}) {
|
|
68
|
+
const files = Array.isArray(bundle.files) ? bundle.files : [];
|
|
69
|
+
const findings = [];
|
|
70
|
+
if (bundle.schema !== TREE_EXPORT_BUNDLE_SCHEMA_ID) findings.push(treeFinding('error', 'export.tree.schema.invalid', 'Tree export bundle schema is invalid.'));
|
|
71
|
+
if (bundle.packageEnvelope === true || files.some((file) => String(file.path || '').startsWith('tiinex.package/'))) {
|
|
72
|
+
findings.push(treeFinding('error', 'export.tree.package-envelope.detected', 'Ordinary tree export must not contain package envelope control files.'));
|
|
73
|
+
}
|
|
74
|
+
const seen = new Set();
|
|
75
|
+
for (const file of files) {
|
|
76
|
+
const path = normalizeTreePath(file.path || '');
|
|
77
|
+
if (!path) findings.push(treeFinding('error', 'export.tree.file.path-invalid', 'Tree export file has an invalid path.', { path: file.path || '' }));
|
|
78
|
+
if (path && seen.has(path)) findings.push(treeFinding('error', 'export.tree.file.path-duplicate', 'Tree export file path is duplicated.', { path }));
|
|
79
|
+
seen.add(path);
|
|
80
|
+
if (isPackageEnvelopePath(path)) findings.push(treeFinding('error', 'export.tree.package-prefix.visible', 'Tree export path still contains a package envelope prefix.', { path }));
|
|
81
|
+
}
|
|
82
|
+
return Object.freeze({
|
|
83
|
+
schema: 'tiinex.export.tree.bundle.inspection.v1',
|
|
84
|
+
status: findings.some((finding) => finding.severity === 'error') ? 'invalid' : findings.some((finding) => finding.severity === 'warning') ? 'degraded' : 'valid',
|
|
85
|
+
counts: Object.freeze({ files: files.length, findings: findings.length, errors: findings.filter((finding) => finding.severity === 'error').length, warnings: findings.filter((finding) => finding.severity === 'warning').length }),
|
|
86
|
+
findings: Object.freeze(findings)
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
|
|
91
|
+
function collectWorkspaceTreeEntries(workspace = {}, input = {}, records = []) {
|
|
92
|
+
const entries = [];
|
|
93
|
+
const seen = new Set();
|
|
94
|
+
const push = (entry = {}, role = 'workspace') => {
|
|
95
|
+
const markdown = String(entry.markdown || entry.workspaceMarkdown || entry.content || '');
|
|
96
|
+
if (!markdown) return;
|
|
97
|
+
const path = normalizeWorkspaceEntryPath(entry.path || entry.logicalPath || entry.name || `${slugPart(entry.title || workspace.title || workspace.name || 'workspace')}.workspace.md`);
|
|
98
|
+
if (!path) return;
|
|
99
|
+
const key = path.toLowerCase();
|
|
100
|
+
if (seen.has(key)) return;
|
|
101
|
+
seen.add(key);
|
|
102
|
+
entries.push(Object.assign({}, entry, { path, markdown, workspaceEntryRole: role }));
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
if (input.workspaceEntry) push(input.workspaceEntry, input.workspaceEntry.workspaceEntryRole || 'current-workspace');
|
|
106
|
+
const importPath = workspace.workspaceImport?.path || '';
|
|
107
|
+
const importMarkdown = workspace.workspaceMarkdown || workspace.workspaceImport?.markdown || '';
|
|
108
|
+
if (importPath || importMarkdown) push({ path: importPath, markdown: importMarkdown, title: workspace.title || workspace.name || '' }, 'current-workspace');
|
|
109
|
+
for (const record of Array.isArray(records) ? records : []) {
|
|
110
|
+
if (!isWorkspaceRecord(record)) continue;
|
|
111
|
+
push({ path: record.path || record.sourcePath || '', markdown: record.markdown || record.content || '', title: record.title || '', id: record.id || '', source: record.source || {}, boundary: record.boundary || '' }, 'workspace-artifact-record');
|
|
112
|
+
}
|
|
113
|
+
for (const entry of Array.isArray(workspace.workspaceMergedEntries) ? workspace.workspaceMergedEntries : []) push(entry, 'merged-workspace');
|
|
114
|
+
// Compatibility-only: old checkpoints/packages may still contain candidate objects.
|
|
115
|
+
for (const entry of Array.isArray(workspace.workspaceMergeCandidates) ? workspace.workspaceMergeCandidates : []) push(entry, 'legacy-workspace-candidate');
|
|
116
|
+
return entries;
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
function treeFileForWorkspaceEntry(entry = {}, findings = []) {
|
|
120
|
+
const path = normalizeWorkspaceEntryPath(entry.path || entry.name || 'workspace.workspace.md');
|
|
121
|
+
const content = String(entry.markdown || entry.workspaceMarkdown || entry.content || '');
|
|
122
|
+
if (!path) {
|
|
123
|
+
findings.push(treeFinding('error', 'export.tree.workspace.path-missing', 'Workspace entry cannot be exported without a safe logical path.', { workspaceEntryId: entry.id || '' }));
|
|
124
|
+
return null;
|
|
125
|
+
}
|
|
126
|
+
if (isPackageEnvelopePath(path)) {
|
|
127
|
+
findings.push(treeFinding('error', 'export.tree.workspace.package-path-refused', 'Workspace entry resolved to a package envelope path; ordinary tree export requires logical workspace paths.', { workspaceEntryId: entry.id || '', path }));
|
|
128
|
+
return null;
|
|
129
|
+
}
|
|
130
|
+
if (!content) {
|
|
131
|
+
findings.push(treeFinding('warning', 'export.tree.workspace.content-missing', 'Workspace entry has no loaded Markdown content and was omitted from the ordinary tree export.', { workspaceEntryId: entry.id || '', path }));
|
|
132
|
+
return null;
|
|
133
|
+
}
|
|
134
|
+
return makeTextFile(path, 'workspace-markdown', content, {
|
|
135
|
+
workspaceEntryId: entry.id || '',
|
|
136
|
+
title: entry.title || '',
|
|
137
|
+
sourceBoundary: entry.source?.boundary || entry.boundary || '',
|
|
138
|
+
presentationPath: path,
|
|
139
|
+
workspaceEntryRole: entry.workspaceEntryRole || 'workspace'
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function normalizeWorkspaceEntryPath(path = '') {
|
|
144
|
+
const clean = normalizeTreePath(path || 'workspace.workspace.md');
|
|
145
|
+
if (!clean) return '';
|
|
146
|
+
if (/\.workspace\.md$/i.test(clean)) return clean;
|
|
147
|
+
return clean.replace(/(?:\.md|\.markdown)?$/i, '.workspace.md');
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function treeFileForRecord(record = {}, findings = [], recordPathMap = null) {
|
|
151
|
+
const logicalPath = recordLogicalPathFromMap(record, recordPathMap);
|
|
152
|
+
const path = normalizeTreePath(logicalPath || record.name || record.title || 'artifact.md');
|
|
153
|
+
const content = String(record.markdown || record.content || record.text || '');
|
|
154
|
+
if (!path) {
|
|
155
|
+
findings.push(treeFinding('error', 'export.tree.record.path-missing', 'Record cannot be exported without a safe logical path.', { recordId: record.id || '' }));
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
if (isPackageEnvelopePath(path)) {
|
|
159
|
+
findings.push(treeFinding('error', 'export.tree.record.package-path-refused', 'Record resolved to a package envelope path; ordinary tree export requires logical material paths.', { recordId: record.id || '', path, logicalPath }));
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
if (!content) {
|
|
163
|
+
findings.push(treeFinding('warning', 'export.tree.record.content-missing', 'Record has no loaded Markdown content and was omitted from the ordinary tree export.', { recordId: record.id || '', path }));
|
|
164
|
+
return null;
|
|
165
|
+
}
|
|
166
|
+
return makeTextFile(path, 'artifact-markdown', content, {
|
|
167
|
+
recordId: record.id || '',
|
|
168
|
+
title: record.title || '',
|
|
169
|
+
sourceBoundary: record.source?.boundary || record.boundary || '',
|
|
170
|
+
provenancePath: record.sourcePath || record.sourceTarget?.sourceArtifactPath || record.snapshot?.sourceArtifactPath || '',
|
|
171
|
+
presentationPath: path,
|
|
172
|
+
logicalPath
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function treeFileForAsset(asset = {}, findings = []) {
|
|
177
|
+
const path = normalizeTreePath(asset.path || asset.name || 'asset');
|
|
178
|
+
const content = typeof asset.content === 'string' && asset.content
|
|
179
|
+
? asset.content
|
|
180
|
+
: typeof asset.dataUrl === 'string' && asset.dataUrl
|
|
181
|
+
? asset.dataUrl
|
|
182
|
+
: typeof asset.text === 'string'
|
|
183
|
+
? asset.text
|
|
184
|
+
: '';
|
|
185
|
+
if (!path) {
|
|
186
|
+
findings.push(treeFinding('error', 'export.tree.asset.path-missing', 'Asset cannot be exported without a safe logical path.', { assetId: asset.id || '' }));
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
if (!content) {
|
|
190
|
+
findings.push(treeFinding('warning', 'export.tree.asset.content-unavailable', 'Asset content was unavailable and was omitted from the ordinary tree export.', { assetId: asset.id || '', path }));
|
|
191
|
+
return null;
|
|
192
|
+
}
|
|
193
|
+
return makeTextFile(path, 'asset-content', content, {
|
|
194
|
+
assetId: asset.id || '',
|
|
195
|
+
title: asset.title || asset.name || '',
|
|
196
|
+
mediaType: asset.type || asset.mediaType || asset.mimeType || 'application/octet-stream',
|
|
197
|
+
presentationPath: path
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function makeTextFile(path, kind, content, extra = {}) {
|
|
202
|
+
const text = String(content || '');
|
|
203
|
+
return Object.freeze(Object.assign({
|
|
204
|
+
path: normalizeTreePath(path),
|
|
205
|
+
kind,
|
|
206
|
+
mediaType: extra.mediaType || (kind === 'artifact-markdown' ? 'text/markdown' : 'application/octet-stream'),
|
|
207
|
+
bytes: text.length,
|
|
208
|
+
content: text
|
|
209
|
+
}, omit(extra, ['mediaType'])));
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function uniqueFiles(files = [], findings = []) {
|
|
213
|
+
const seen = new Map();
|
|
214
|
+
return files.map((file) => {
|
|
215
|
+
const path = normalizeTreePath(file.path || '');
|
|
216
|
+
if (!seen.has(path)) {
|
|
217
|
+
seen.set(path, 0);
|
|
218
|
+
return file;
|
|
219
|
+
}
|
|
220
|
+
const next = seen.get(path) + 1;
|
|
221
|
+
seen.set(path, next);
|
|
222
|
+
const renamedPath = addPathSuffix(path, `duplicate-${next}`);
|
|
223
|
+
findings.push(treeFinding('warning', 'export.tree.path-deduped', 'Duplicate tree export path was made unique.', { path, renamedPath }));
|
|
224
|
+
return Object.freeze(Object.assign({}, file, { path: renamedPath, presentationPath: renamedPath }));
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
function addPathSuffix(path, suffix) {
|
|
229
|
+
const slash = path.lastIndexOf('/');
|
|
230
|
+
const dot = path.lastIndexOf('.');
|
|
231
|
+
if (dot <= slash) return `${path}.${suffix}`;
|
|
232
|
+
return `${path.slice(0, dot)}.${suffix}${path.slice(dot)}`;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
export function normalizeTreePath(path = '') {
|
|
236
|
+
const input = String(path || '').trim().replace(/\\/g, '/').replace(/^\/+/, '');
|
|
237
|
+
const parts = [];
|
|
238
|
+
for (const part of input.split('/')) {
|
|
239
|
+
const clean = part.trim();
|
|
240
|
+
if (!clean || clean === '.') continue;
|
|
241
|
+
if (clean === '..') continue;
|
|
242
|
+
parts.push(clean.replace(/[\u0000-\u001f<>:"|?*]/g, '_'));
|
|
243
|
+
}
|
|
244
|
+
const output = parts.join('/');
|
|
245
|
+
if (!output) return '';
|
|
246
|
+
if (/\.(?:md|markdown|trace\.md|schema\.md|validator\.md|workspace\.md)$/i.test(output)) return output;
|
|
247
|
+
const leaf = output.split('/').filter(Boolean).pop() || '';
|
|
248
|
+
return leaf.includes('.') ? output : `${output}.md`;
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
function slugPart(value = '') {
|
|
252
|
+
return String(value || 'workspace').toLowerCase().normalize('NFKD').replace(/[\u0300-\u036f]/g, '').replace(/[^a-z0-9]+/g, '-').replace(/^-|-$/g, '').slice(0, 60) || 'workspace';
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
function isPackageEnvelopePath(path = '') {
|
|
256
|
+
const clean = String(path || '').replace(/\\/g, '/').replace(/^\/+/, '');
|
|
257
|
+
return clean === 'artifacts' || clean.startsWith('artifacts/')
|
|
258
|
+
|| clean === 'tiinex.package' || clean.startsWith('tiinex.package/')
|
|
259
|
+
|| clean === 'workspace-candidates' || clean.startsWith('workspace-candidates/');
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
function omit(value = {}, keys = []) {
|
|
263
|
+
const remove = new Set(keys);
|
|
264
|
+
const out = {};
|
|
265
|
+
for (const [key, item] of Object.entries(value || {})) if (!remove.has(key)) out[key] = item;
|
|
266
|
+
return out;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
function treeFinding(severity, code, message, extra = {}) {
|
|
270
|
+
return Object.freeze(Object.assign({ severity, code, message }, extra));
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
function deepFreeze(value) {
|
|
274
|
+
if (!value || typeof value !== 'object' || Object.isFrozen(value)) return value;
|
|
275
|
+
Object.freeze(value);
|
|
276
|
+
for (const item of Object.values(value)) deepFreeze(item);
|
|
277
|
+
return value;
|
|
278
|
+
}
|