@owlmeans/viable-common 0.0.4
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/README.md +68 -0
- package/agent-meta/manifest.json +16 -0
- package/agent-meta/skills/viable-common/SKILL.md +179 -0
- package/build/agent/index.d.ts +4 -0
- package/build/agent/index.d.ts.map +1 -0
- package/build/agent/index.js +3 -0
- package/build/agent/index.js.map +1 -0
- package/build/agent/memory.d.ts +12 -0
- package/build/agent/memory.d.ts.map +1 -0
- package/build/agent/memory.js +11 -0
- package/build/agent/memory.js.map +1 -0
- package/build/agent/spectator/consts.d.ts +9 -0
- package/build/agent/spectator/consts.d.ts.map +1 -0
- package/build/agent/spectator/consts.js +10 -0
- package/build/agent/spectator/consts.js.map +1 -0
- package/build/agent/spectator/index.d.ts +3 -0
- package/build/agent/spectator/index.d.ts.map +1 -0
- package/build/agent/spectator/index.js +2 -0
- package/build/agent/spectator/index.js.map +1 -0
- package/build/agent/spectator/types.d.ts +13 -0
- package/build/agent/spectator/types.d.ts.map +1 -0
- package/build/agent/spectator/types.js +2 -0
- package/build/agent/spectator/types.js.map +1 -0
- package/build/agent/types.d.ts +10 -0
- package/build/agent/types.d.ts.map +1 -0
- package/build/agent/types.js +2 -0
- package/build/agent/types.js.map +1 -0
- package/build/areas/consts.d.ts +88 -0
- package/build/areas/consts.d.ts.map +1 -0
- package/build/areas/consts.js +106 -0
- package/build/areas/consts.js.map +1 -0
- package/build/areas/index.d.ts +3 -0
- package/build/areas/index.d.ts.map +1 -0
- package/build/areas/index.js +2 -0
- package/build/areas/index.js.map +1 -0
- package/build/areas/types.d.ts +28 -0
- package/build/areas/types.d.ts.map +1 -0
- package/build/areas/types.js +2 -0
- package/build/areas/types.js.map +1 -0
- package/build/ba/consts.d.ts +38 -0
- package/build/ba/consts.d.ts.map +1 -0
- package/build/ba/consts.js +41 -0
- package/build/ba/consts.js.map +1 -0
- package/build/ba/helpers.d.ts +41 -0
- package/build/ba/helpers.d.ts.map +1 -0
- package/build/ba/helpers.js +79 -0
- package/build/ba/helpers.js.map +1 -0
- package/build/ba/index.d.ts +5 -0
- package/build/ba/index.d.ts.map +1 -0
- package/build/ba/index.js +4 -0
- package/build/ba/index.js.map +1 -0
- package/build/ba/schemas.d.ts +13 -0
- package/build/ba/schemas.d.ts.map +1 -0
- package/build/ba/schemas.js +181 -0
- package/build/ba/schemas.js.map +1 -0
- package/build/ba/types.d.ts +113 -0
- package/build/ba/types.d.ts.map +1 -0
- package/build/ba/types.js +2 -0
- package/build/ba/types.js.map +1 -0
- package/build/blueprint/case.d.ts +73 -0
- package/build/blueprint/case.d.ts.map +1 -0
- package/build/blueprint/case.js +244 -0
- package/build/blueprint/case.js.map +1 -0
- package/build/blueprint/consts.d.ts +11 -0
- package/build/blueprint/consts.d.ts.map +1 -0
- package/build/blueprint/consts.js +11 -0
- package/build/blueprint/consts.js.map +1 -0
- package/build/blueprint/index.d.ts +6 -0
- package/build/blueprint/index.d.ts.map +1 -0
- package/build/blueprint/index.js +6 -0
- package/build/blueprint/index.js.map +1 -0
- package/build/blueprint/resolve.d.ts +51 -0
- package/build/blueprint/resolve.d.ts.map +1 -0
- package/build/blueprint/resolve.js +108 -0
- package/build/blueprint/resolve.js.map +1 -0
- package/build/blueprint/schemas.d.ts +41 -0
- package/build/blueprint/schemas.d.ts.map +1 -0
- package/build/blueprint/schemas.js +27 -0
- package/build/blueprint/schemas.js.map +1 -0
- package/build/blueprint/types.d.ts +186 -0
- package/build/blueprint/types.d.ts.map +1 -0
- package/build/blueprint/types.js +32 -0
- package/build/blueprint/types.js.map +1 -0
- package/build/branding.d.ts +19 -0
- package/build/branding.d.ts.map +1 -0
- package/build/branding.js +32 -0
- package/build/branding.js.map +1 -0
- package/build/connect/consts.d.ts +378 -0
- package/build/connect/consts.d.ts.map +1 -0
- package/build/connect/consts.js +425 -0
- package/build/connect/consts.js.map +1 -0
- package/build/connect/entrypoints.d.ts +41 -0
- package/build/connect/entrypoints.d.ts.map +1 -0
- package/build/connect/entrypoints.js +141 -0
- package/build/connect/entrypoints.js.map +1 -0
- package/build/connect/errors.d.ts +50 -0
- package/build/connect/errors.d.ts.map +1 -0
- package/build/connect/errors.js +77 -0
- package/build/connect/errors.js.map +1 -0
- package/build/connect/index.d.ts +8 -0
- package/build/connect/index.d.ts.map +1 -0
- package/build/connect/index.js +6 -0
- package/build/connect/index.js.map +1 -0
- package/build/connect/ops.d.ts +192 -0
- package/build/connect/ops.d.ts.map +1 -0
- package/build/connect/ops.js +2 -0
- package/build/connect/ops.js.map +1 -0
- package/build/connect/references.d.ts +194 -0
- package/build/connect/references.d.ts.map +1 -0
- package/build/connect/references.js +62 -0
- package/build/connect/references.js.map +1 -0
- package/build/connect/schemas.d.ts +59 -0
- package/build/connect/schemas.d.ts.map +1 -0
- package/build/connect/schemas.js +346 -0
- package/build/connect/schemas.js.map +1 -0
- package/build/connect/types.d.ts +428 -0
- package/build/connect/types.d.ts.map +1 -0
- package/build/connect/types.js +2 -0
- package/build/connect/types.js.map +1 -0
- package/build/consts.d.ts +9 -0
- package/build/consts.d.ts.map +1 -0
- package/build/consts.js +31 -0
- package/build/consts.js.map +1 -0
- package/build/convert/consts.d.ts +539 -0
- package/build/convert/consts.d.ts.map +1 -0
- package/build/convert/consts.js +630 -0
- package/build/convert/consts.js.map +1 -0
- package/build/convert/helpers.d.ts +91 -0
- package/build/convert/helpers.d.ts.map +1 -0
- package/build/convert/helpers.js +301 -0
- package/build/convert/helpers.js.map +1 -0
- package/build/convert/index.d.ts +11 -0
- package/build/convert/index.d.ts.map +1 -0
- package/build/convert/index.js +4 -0
- package/build/convert/index.js.map +1 -0
- package/build/convert/schemas.d.ts +62 -0
- package/build/convert/schemas.d.ts.map +1 -0
- package/build/convert/schemas.js +626 -0
- package/build/convert/schemas.js.map +1 -0
- package/build/convert/types.d.ts +683 -0
- package/build/convert/types.d.ts.map +1 -0
- package/build/convert/types.js +2 -0
- package/build/convert/types.js.map +1 -0
- package/build/design/consts.d.ts +25 -0
- package/build/design/consts.d.ts.map +1 -0
- package/build/design/consts.js +26 -0
- package/build/design/consts.js.map +1 -0
- package/build/design/helpers.d.ts +60 -0
- package/build/design/helpers.d.ts.map +1 -0
- package/build/design/helpers.js +221 -0
- package/build/design/helpers.js.map +1 -0
- package/build/design/index.d.ts +6 -0
- package/build/design/index.d.ts.map +1 -0
- package/build/design/index.js +5 -0
- package/build/design/index.js.map +1 -0
- package/build/design/runtime.d.ts +126 -0
- package/build/design/runtime.d.ts.map +1 -0
- package/build/design/runtime.js +65 -0
- package/build/design/runtime.js.map +1 -0
- package/build/design/schemas.d.ts +21 -0
- package/build/design/schemas.d.ts.map +1 -0
- package/build/design/schemas.js +369 -0
- package/build/design/schemas.js.map +1 -0
- package/build/design/types.d.ts +199 -0
- package/build/design/types.d.ts.map +1 -0
- package/build/design/types.js +2 -0
- package/build/design/types.js.map +1 -0
- package/build/dev/consts.d.ts +32 -0
- package/build/dev/consts.d.ts.map +1 -0
- package/build/dev/consts.js +33 -0
- package/build/dev/consts.js.map +1 -0
- package/build/dev/index.d.ts +4 -0
- package/build/dev/index.d.ts.map +1 -0
- package/build/dev/index.js +3 -0
- package/build/dev/index.js.map +1 -0
- package/build/dev/schemas.d.ts +15 -0
- package/build/dev/schemas.d.ts.map +1 -0
- package/build/dev/schemas.js +116 -0
- package/build/dev/schemas.js.map +1 -0
- package/build/dev/types.d.ts +42 -0
- package/build/dev/types.d.ts.map +1 -0
- package/build/dev/types.js +2 -0
- package/build/dev/types.js.map +1 -0
- package/build/execution/consts.d.ts +36 -0
- package/build/execution/consts.d.ts.map +1 -0
- package/build/execution/consts.js +37 -0
- package/build/execution/consts.js.map +1 -0
- package/build/execution/index.d.ts +3 -0
- package/build/execution/index.d.ts.map +1 -0
- package/build/execution/index.js +2 -0
- package/build/execution/index.js.map +1 -0
- package/build/execution/types.d.ts +50 -0
- package/build/execution/types.d.ts.map +1 -0
- package/build/execution/types.js +2 -0
- package/build/execution/types.js.map +1 -0
- package/build/index.d.ts +22 -0
- package/build/index.d.ts.map +1 -0
- package/build/index.js +21 -0
- package/build/index.js.map +1 -0
- package/build/integrity/consts.d.ts +226 -0
- package/build/integrity/consts.d.ts.map +1 -0
- package/build/integrity/consts.js +401 -0
- package/build/integrity/consts.js.map +1 -0
- package/build/integrity/index.d.ts +4 -0
- package/build/integrity/index.d.ts.map +1 -0
- package/build/integrity/index.js +3 -0
- package/build/integrity/index.js.map +1 -0
- package/build/integrity/types.d.ts +35 -0
- package/build/integrity/types.d.ts.map +1 -0
- package/build/integrity/types.js +2 -0
- package/build/integrity/types.js.map +1 -0
- package/build/integrity/verify.d.ts +23 -0
- package/build/integrity/verify.d.ts.map +1 -0
- package/build/integrity/verify.js +198 -0
- package/build/integrity/verify.js.map +1 -0
- package/build/metadata/consts.d.ts +101 -0
- package/build/metadata/consts.d.ts.map +1 -0
- package/build/metadata/consts.js +104 -0
- package/build/metadata/consts.js.map +1 -0
- package/build/metadata/index.d.ts +3 -0
- package/build/metadata/index.d.ts.map +1 -0
- package/build/metadata/index.js +3 -0
- package/build/metadata/index.js.map +1 -0
- package/build/metadata/types.d.ts +286 -0
- package/build/metadata/types.d.ts.map +1 -0
- package/build/metadata/types.js +39 -0
- package/build/metadata/types.js.map +1 -0
- package/build/moderation/consts.d.ts +58 -0
- package/build/moderation/consts.d.ts.map +1 -0
- package/build/moderation/consts.js +60 -0
- package/build/moderation/consts.js.map +1 -0
- package/build/moderation/index.d.ts +5 -0
- package/build/moderation/index.d.ts.map +1 -0
- package/build/moderation/index.js +4 -0
- package/build/moderation/index.js.map +1 -0
- package/build/moderation/schemas.d.ts +19 -0
- package/build/moderation/schemas.d.ts.map +1 -0
- package/build/moderation/schemas.js +26 -0
- package/build/moderation/schemas.js.map +1 -0
- package/build/moderation/types.d.ts +64 -0
- package/build/moderation/types.d.ts.map +1 -0
- package/build/moderation/types.js +2 -0
- package/build/moderation/types.js.map +1 -0
- package/build/moderation/utils.d.ts +21 -0
- package/build/moderation/utils.d.ts.map +1 -0
- package/build/moderation/utils.js +31 -0
- package/build/moderation/utils.js.map +1 -0
- package/build/preview/consts.d.ts +10 -0
- package/build/preview/consts.d.ts.map +1 -0
- package/build/preview/consts.js +11 -0
- package/build/preview/consts.js.map +1 -0
- package/build/preview/index.d.ts +3 -0
- package/build/preview/index.d.ts.map +1 -0
- package/build/preview/index.js +2 -0
- package/build/preview/index.js.map +1 -0
- package/build/preview/types.d.ts +60 -0
- package/build/preview/types.d.ts.map +1 -0
- package/build/preview/types.js +2 -0
- package/build/preview/types.js.map +1 -0
- package/build/scaffold/consts.d.ts +25 -0
- package/build/scaffold/consts.d.ts.map +1 -0
- package/build/scaffold/consts.js +26 -0
- package/build/scaffold/consts.js.map +1 -0
- package/build/scaffold/helpers.d.ts +35 -0
- package/build/scaffold/helpers.d.ts.map +1 -0
- package/build/scaffold/helpers.js +54 -0
- package/build/scaffold/helpers.js.map +1 -0
- package/build/scaffold/index.d.ts +5 -0
- package/build/scaffold/index.d.ts.map +1 -0
- package/build/scaffold/index.js +4 -0
- package/build/scaffold/index.js.map +1 -0
- package/build/scaffold/schemas.d.ts +5 -0
- package/build/scaffold/schemas.d.ts.map +1 -0
- package/build/scaffold/schemas.js +273 -0
- package/build/scaffold/schemas.js.map +1 -0
- package/build/scaffold/types.d.ts +144 -0
- package/build/scaffold/types.d.ts.map +1 -0
- package/build/scaffold/types.js +2 -0
- package/build/scaffold/types.js.map +1 -0
- package/build/skills/catalogue.d.ts +47 -0
- package/build/skills/catalogue.d.ts.map +1 -0
- package/build/skills/catalogue.js +1566 -0
- package/build/skills/catalogue.js.map +1 -0
- package/build/skills/consts.d.ts +104 -0
- package/build/skills/consts.d.ts.map +1 -0
- package/build/skills/consts.js +170 -0
- package/build/skills/consts.js.map +1 -0
- package/build/skills/index.d.ts +4 -0
- package/build/skills/index.d.ts.map +1 -0
- package/build/skills/index.js +4 -0
- package/build/skills/index.js.map +1 -0
- package/build/skills/roles.d.ts +52 -0
- package/build/skills/roles.d.ts.map +1 -0
- package/build/skills/roles.js +256 -0
- package/build/skills/roles.js.map +1 -0
- package/build/slot/consts.d.ts +305 -0
- package/build/slot/consts.d.ts.map +1 -0
- package/build/slot/consts.js +376 -0
- package/build/slot/consts.js.map +1 -0
- package/build/slot/helpers.d.ts +25 -0
- package/build/slot/helpers.d.ts.map +1 -0
- package/build/slot/helpers.js +27 -0
- package/build/slot/helpers.js.map +1 -0
- package/build/slot/index.d.ts +6 -0
- package/build/slot/index.d.ts.map +1 -0
- package/build/slot/index.js +5 -0
- package/build/slot/index.js.map +1 -0
- package/build/slot/layout.d.ts +72 -0
- package/build/slot/layout.d.ts.map +1 -0
- package/build/slot/layout.js +82 -0
- package/build/slot/layout.js.map +1 -0
- package/build/slot/schemas.d.ts +12 -0
- package/build/slot/schemas.d.ts.map +1 -0
- package/build/slot/schemas.js +43 -0
- package/build/slot/schemas.js.map +1 -0
- package/build/slot/types.d.ts +147 -0
- package/build/slot/types.d.ts.map +1 -0
- package/build/slot/types.js +2 -0
- package/build/slot/types.js.map +1 -0
- package/build/topology/card.d.ts +23 -0
- package/build/topology/card.d.ts.map +1 -0
- package/build/topology/card.js +95 -0
- package/build/topology/card.js.map +1 -0
- package/build/topology/consts.d.ts +32 -0
- package/build/topology/consts.d.ts.map +1 -0
- package/build/topology/consts.js +55 -0
- package/build/topology/consts.js.map +1 -0
- package/build/topology/helpers.d.ts +44 -0
- package/build/topology/helpers.d.ts.map +1 -0
- package/build/topology/helpers.js +112 -0
- package/build/topology/helpers.js.map +1 -0
- package/build/topology/index.d.ts +5 -0
- package/build/topology/index.d.ts.map +1 -0
- package/build/topology/index.js +4 -0
- package/build/topology/index.js.map +1 -0
- package/build/topology/types.d.ts +83 -0
- package/build/topology/types.d.ts.map +1 -0
- package/build/topology/types.js +2 -0
- package/build/topology/types.js.map +1 -0
- package/build/types.d.ts +88 -0
- package/build/types.d.ts.map +1 -0
- package/build/types.js +2 -0
- package/build/types.js.map +1 -0
- package/build/ux/consts.d.ts +5 -0
- package/build/ux/consts.d.ts.map +1 -0
- package/build/ux/consts.js +6 -0
- package/build/ux/consts.js.map +1 -0
- package/build/ux/index.d.ts +4 -0
- package/build/ux/index.d.ts.map +1 -0
- package/build/ux/index.js +3 -0
- package/build/ux/index.js.map +1 -0
- package/build/ux/schemas.d.ts +8 -0
- package/build/ux/schemas.d.ts.map +1 -0
- package/build/ux/schemas.js +91 -0
- package/build/ux/schemas.js.map +1 -0
- package/build/ux/types.d.ts +21 -0
- package/build/ux/types.d.ts.map +1 -0
- package/build/ux/types.js +2 -0
- package/build/ux/types.js.map +1 -0
- package/package.json +71 -0
- package/src/agent/index.ts +4 -0
- package/src/agent/memory.ts +16 -0
- package/src/agent/spectator/consts.ts +10 -0
- package/src/agent/spectator/index.ts +3 -0
- package/src/agent/spectator/types.ts +14 -0
- package/src/agent/types.ts +10 -0
- package/src/areas/consts.ts +112 -0
- package/src/areas/index.ts +3 -0
- package/src/areas/types.ts +29 -0
- package/src/ba/consts.ts +40 -0
- package/src/ba/helpers.ts +93 -0
- package/src/ba/index.ts +5 -0
- package/src/ba/schemas.ts +196 -0
- package/src/ba/types.ts +125 -0
- package/src/blueprint/case.ts +272 -0
- package/src/blueprint/consts.ts +11 -0
- package/src/blueprint/index.ts +6 -0
- package/src/blueprint/resolve.ts +133 -0
- package/src/blueprint/schemas.ts +44 -0
- package/src/blueprint/types.ts +204 -0
- package/src/branding.ts +34 -0
- package/src/connect/consts.ts +441 -0
- package/src/connect/entrypoints.ts +291 -0
- package/src/connect/errors.ts +91 -0
- package/src/connect/index.ts +7 -0
- package/src/connect/ops.ts +208 -0
- package/src/connect/references.ts +89 -0
- package/src/connect/schemas.ts +384 -0
- package/src/connect/types.ts +456 -0
- package/src/consts.ts +34 -0
- package/src/convert/consts.ts +672 -0
- package/src/convert/helpers.ts +340 -0
- package/src/convert/index.ts +10 -0
- package/src/convert/schemas.ts +663 -0
- package/src/convert/types.ts +741 -0
- package/src/design/consts.ts +26 -0
- package/src/design/helpers.ts +255 -0
- package/src/design/index.ts +5 -0
- package/src/design/runtime.ts +142 -0
- package/src/design/schemas.ts +384 -0
- package/src/design/types.ts +191 -0
- package/src/dev/consts.ts +35 -0
- package/src/dev/index.ts +4 -0
- package/src/dev/schemas.ts +124 -0
- package/src/dev/types.ts +47 -0
- package/src/execution/consts.ts +37 -0
- package/src/execution/index.ts +3 -0
- package/src/execution/types.ts +55 -0
- package/src/index.ts +22 -0
- package/src/integrity/consts.ts +477 -0
- package/src/integrity/index.ts +3 -0
- package/src/integrity/types.ts +37 -0
- package/src/integrity/verify.ts +221 -0
- package/src/metadata/consts.ts +118 -0
- package/src/metadata/index.ts +3 -0
- package/src/metadata/types.ts +310 -0
- package/src/moderation/consts.ts +59 -0
- package/src/moderation/index.ts +4 -0
- package/src/moderation/schemas.ts +28 -0
- package/src/moderation/types.ts +68 -0
- package/src/moderation/utils.ts +35 -0
- package/src/preview/consts.ts +9 -0
- package/src/preview/index.ts +3 -0
- package/src/preview/types.ts +79 -0
- package/src/scaffold/consts.ts +26 -0
- package/src/scaffold/helpers.ts +84 -0
- package/src/scaffold/index.ts +4 -0
- package/src/scaffold/schemas.ts +283 -0
- package/src/scaffold/types.ts +118 -0
- package/src/skills/catalogue.ts +1617 -0
- package/src/skills/consts.ts +183 -0
- package/src/skills/index.ts +4 -0
- package/src/skills/roles.ts +299 -0
- package/src/slot/consts.ts +393 -0
- package/src/slot/helpers.ts +34 -0
- package/src/slot/index.ts +5 -0
- package/src/slot/layout.ts +141 -0
- package/src/slot/schemas.ts +46 -0
- package/src/slot/types.ts +164 -0
- package/src/topology/card.ts +106 -0
- package/src/topology/consts.ts +59 -0
- package/src/topology/helpers.ts +138 -0
- package/src/topology/index.ts +5 -0
- package/src/topology/types.ts +86 -0
- package/src/types.ts +104 -0
- package/src/ux/consts.ts +5 -0
- package/src/ux/index.ts +4 -0
- package/src/ux/schemas.ts +97 -0
- package/src/ux/types.ts +25 -0
- package/tests/connect-convert.spec.ts +161 -0
- package/tests/convert.spec.ts +318 -0
- package/tests/design.spec.ts +136 -0
- package/tsconfig.json +16 -0
|
@@ -0,0 +1,340 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ArchitectureCase, ConversionDecision, ConversionStage, CONVERSION_STAGE_ORDER,
|
|
3
|
+
CONVERTED_ORIGIN_DIR, EntropyClass, FileClass, ORIGIN_CARD_MAX_CHARS, SizeClass,
|
|
4
|
+
SIZE_CLASS_BOUNDS
|
|
5
|
+
} from './consts.js'
|
|
6
|
+
import type { OriginCard, StoryProof } from './types.js'
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Pure, deterministic derivations over the conversion vocabulary.
|
|
10
|
+
*
|
|
11
|
+
* Everything here answers the same way for the same input, in every runtime, forever — which is
|
|
12
|
+
* what makes the documents a conversion writes byte-stable across two runs, and therefore what
|
|
13
|
+
* makes the prompt cache prefix they are injected into actually hit. Nothing in this file reads a
|
|
14
|
+
* file, calls a model or looks at a clock.
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/** Which {@link SizeClass} a byte count falls in. Boundaries are exclusive upper bounds. */
|
|
18
|
+
export const sizeClassOf = (bytes: number): SizeClass => {
|
|
19
|
+
if (bytes < SIZE_CLASS_BOUNDS[SizeClass.Tiny]) return SizeClass.Tiny
|
|
20
|
+
if (bytes < SIZE_CLASS_BOUNDS[SizeClass.Small]) return SizeClass.Small
|
|
21
|
+
if (bytes < SIZE_CLASS_BOUNDS[SizeClass.Medium]) return SizeClass.Medium
|
|
22
|
+
if (bytes < SIZE_CLASS_BOUNDS[SizeClass.Large]) return SizeClass.Large
|
|
23
|
+
|
|
24
|
+
return SizeClass.Huge
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Extension → class, for the extensions that decide a file on their own.
|
|
29
|
+
*
|
|
30
|
+
* Deliberately not exhaustive: a path rule below overrides it wherever the location says more than
|
|
31
|
+
* the tail does (a `.ts` under `tests/` is a test, a `.json` under `seed/` is data).
|
|
32
|
+
*/
|
|
33
|
+
const EXT_CLASS: Record<string, FileClass> = {
|
|
34
|
+
ts: FileClass.Source, tsx: FileClass.Source, js: FileClass.Source, jsx: FileClass.Source,
|
|
35
|
+
mjs: FileClass.Source, cjs: FileClass.Source, mts: FileClass.Source, cts: FileClass.Source,
|
|
36
|
+
vue: FileClass.Source, svelte: FileClass.Source, java: FileClass.Source, kt: FileClass.Source,
|
|
37
|
+
kts: FileClass.Source, go: FileClass.Source, py: FileClass.Source, rb: FileClass.Source,
|
|
38
|
+
php: FileClass.Source, cs: FileClass.Source, ex: FileClass.Source, exs: FileClass.Source,
|
|
39
|
+
rs: FileClass.Source, sql: FileClass.Source, sh: FileClass.Source,
|
|
40
|
+
|
|
41
|
+
css: FileClass.Style, scss: FileClass.Style, sass: FileClass.Style, less: FileClass.Style,
|
|
42
|
+
styl: FileClass.Style,
|
|
43
|
+
|
|
44
|
+
md: FileClass.Doc, mdx: FileClass.Doc, rst: FileClass.Doc, adoc: FileClass.Doc,
|
|
45
|
+
txt: FileClass.Doc,
|
|
46
|
+
|
|
47
|
+
json: FileClass.Config, yaml: FileClass.Config, yml: FileClass.Config, toml: FileClass.Config,
|
|
48
|
+
ini: FileClass.Config, env: FileClass.Config, properties: FileClass.Config,
|
|
49
|
+
xml: FileClass.Config, conf: FileClass.Config,
|
|
50
|
+
|
|
51
|
+
html: FileClass.Template, htm: FileClass.Template, hbs: FileClass.Template,
|
|
52
|
+
ejs: FileClass.Template, pug: FileClass.Template, twig: FileClass.Template,
|
|
53
|
+
erb: FileClass.Template, jinja: FileClass.Template, j2: FileClass.Template,
|
|
54
|
+
|
|
55
|
+
csv: FileClass.Data, tsv: FileClass.Data, ndjson: FileClass.Data, jsonl: FileClass.Data,
|
|
56
|
+
parquet: FileClass.Data, dump: FileClass.Data,
|
|
57
|
+
|
|
58
|
+
png: FileClass.Binary, jpg: FileClass.Binary, jpeg: FileClass.Binary, gif: FileClass.Binary,
|
|
59
|
+
webp: FileClass.Binary, ico: FileClass.Binary, pdf: FileClass.Binary, zip: FileClass.Binary,
|
|
60
|
+
gz: FileClass.Binary, tar: FileClass.Binary, woff: FileClass.Binary, woff2: FileClass.Binary,
|
|
61
|
+
ttf: FileClass.Binary, otf: FileClass.Binary, mp4: FileClass.Binary, mp3: FileClass.Binary,
|
|
62
|
+
wasm: FileClass.Binary, jar: FileClass.Binary, so: FileClass.Binary, dll: FileClass.Binary,
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Exact basenames that are a package manifest whatever their extension says. */
|
|
66
|
+
const MANIFEST_NAMES = [
|
|
67
|
+
'package.json', 'deno.json', 'pom.xml', 'build.gradle', 'build.gradle.kts',
|
|
68
|
+
'settings.gradle', 'settings.gradle.kts', 'go.mod', 'cargo.toml', 'pyproject.toml',
|
|
69
|
+
'requirements.txt', 'pipfile', 'composer.json', 'gemfile', 'mix.exs',
|
|
70
|
+
]
|
|
71
|
+
|
|
72
|
+
/** Exact basenames that are a lockfile — never read, never counted as source. */
|
|
73
|
+
const LOCK_NAMES = [
|
|
74
|
+
'bun.lock', 'bun.lockb', 'package-lock.json', 'yarn.lock', 'pnpm-lock.yaml', 'go.sum',
|
|
75
|
+
'cargo.lock', 'composer.lock', 'gemfile.lock', 'poetry.lock', 'pipfile.lock', 'mix.lock',
|
|
76
|
+
]
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Path segments whose contents are produced by a build and say nothing about the application.
|
|
80
|
+
*
|
|
81
|
+
* `bin` is deliberately absent though `obj` is here: it is .NET/Java output in two of the nine
|
|
82
|
+
* ecosystems the converter reads and a real entrypoint directory in the rest (`bin/cli.ts`,
|
|
83
|
+
* `bin/console`, `bin/rails`), and this function is handed one path with no tree around it to
|
|
84
|
+
* tell the two apart. Dropping those entrypoints out of every source listing is the worse error.
|
|
85
|
+
*/
|
|
86
|
+
const GENERATED_SEGMENTS = [
|
|
87
|
+
'node_modules', 'dist', 'build', 'out', 'target', 'vendor', '.next', '.nuxt', '.svelte-kit',
|
|
88
|
+
'.turbo', '.gradle', '__pycache__', 'coverage', '.venv', 'obj',
|
|
89
|
+
]
|
|
90
|
+
|
|
91
|
+
/** Path segments that make a file a test wherever its extension would have said otherwise. */
|
|
92
|
+
const TEST_SEGMENTS = ['test', 'tests', '__tests__', 'spec', 'specs', 'e2e']
|
|
93
|
+
|
|
94
|
+
const segmentsOf = (path: string): string[] => path.split('/').filter(part => part !== '')
|
|
95
|
+
|
|
96
|
+
const hasSegment = (path: string, of: string[]): boolean =>
|
|
97
|
+
segmentsOf(path).some(part => of.includes(part.toLowerCase()))
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* The classes a seed or dump LOCATION is allowed to override.
|
|
101
|
+
*
|
|
102
|
+
* A seed directory says what a file holds, not what language it is written in — so it reclassifies
|
|
103
|
+
* a payload and never a program. `seed/users.json` is data; `src/seedUsers.ts` is the code that
|
|
104
|
+
* loads it, and `src/exportReport.ts` is a screen, and pushing either into the data budget takes
|
|
105
|
+
* real source out of the census's reach.
|
|
106
|
+
*/
|
|
107
|
+
const DATA_OVERRIDABLE: FileClass[] = [
|
|
108
|
+
FileClass.Data, FileClass.Config, FileClass.Binary, FileClass.Unknown,
|
|
109
|
+
]
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* The extensions that are as often a dump as they are a program.
|
|
113
|
+
*
|
|
114
|
+
* A `.sql` under `migrations/` is schema somebody wrote and a coder has to reproduce; the same
|
|
115
|
+
* tail under `dumps/` is an export nothing should read into a prompt. The location is the only
|
|
116
|
+
* thing that separates them, so it outranks the tail for these and for no other language.
|
|
117
|
+
*/
|
|
118
|
+
const DATA_AMBIGUOUS_EXT = ['sql']
|
|
119
|
+
|
|
120
|
+
/**
|
|
121
|
+
* What one file of the origin is.
|
|
122
|
+
*
|
|
123
|
+
* Location outranks the tail wherever it says more — a `.ts` under `__tests__/` is a test, a
|
|
124
|
+
* `.json` under `seed/` is data — but only where it says more. The seed/dump rule therefore runs
|
|
125
|
+
* AFTER the extension table and applies only to {@link DATA_OVERRIDABLE}: asked first, it answered
|
|
126
|
+
* `Data` for every path merely containing the word (`tests/fixtures/user.ts`, `src/seedUsers.ts`,
|
|
127
|
+
* `src/exportReport.ts`), which is the census's source budget spent on the wrong files twice over.
|
|
128
|
+
*/
|
|
129
|
+
export const fileClassOf = (path: string, ext: string): FileClass => {
|
|
130
|
+
const lower = path.toLowerCase()
|
|
131
|
+
const base = segmentsOf(lower).pop() ?? lower
|
|
132
|
+
const tail = (ext.startsWith('.') ? ext.slice(1) : ext).toLowerCase()
|
|
133
|
+
|
|
134
|
+
if (LOCK_NAMES.includes(base)) return FileClass.Lock
|
|
135
|
+
if (hasSegment(lower, GENERATED_SEGMENTS)) return FileClass.Generated
|
|
136
|
+
if (MANIFEST_NAMES.includes(base)) return FileClass.Manifest
|
|
137
|
+
if (hasSegment(lower, TEST_SEGMENTS) || base.includes('.test.') || base.includes('.spec.')) {
|
|
138
|
+
return FileClass.Test
|
|
139
|
+
}
|
|
140
|
+
if (base.startsWith('.env')) return FileClass.Config
|
|
141
|
+
|
|
142
|
+
const byExt = EXT_CLASS[tail] ?? FileClass.Unknown
|
|
143
|
+
if (
|
|
144
|
+
(DATA_OVERRIDABLE.includes(byExt) || DATA_AMBIGUOUS_EXT.includes(tail))
|
|
145
|
+
&& (isSeedPath(lower) || isBulkPath(lower))
|
|
146
|
+
) {
|
|
147
|
+
return FileClass.Data
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return byExt
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Extensions whose tail already answers the binary question, either way.
|
|
155
|
+
*
|
|
156
|
+
* Deliberately two lists and not one with a default: an extension the census has never seen must
|
|
157
|
+
* be READ rather than guessed at, because a repository nobody here wrote carries tails nobody
|
|
158
|
+
* here chose. Nothing in either list is a guess about content — a `.ts` holding a NUL byte is a
|
|
159
|
+
* corrupt file, and a `.png` that is not binary is not a `.png`.
|
|
160
|
+
*/
|
|
161
|
+
const TEXT_EXTENSIONS: readonly string[] = [
|
|
162
|
+
'.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '.mts', '.cts', '.json', '.jsonc',
|
|
163
|
+
'.md', '.mdx', '.txt', '.css', '.scss', '.sass', '.less', '.html', '.htm', '.xml', '.svg',
|
|
164
|
+
'.yml', '.yaml', '.toml', '.ini', '.env', '.sh', '.bash', '.zsh', '.sql', '.graphql', '.gql',
|
|
165
|
+
'.py', '.rb', '.go', '.rs', '.java', '.kt', '.php', '.cs', '.c', '.h', '.cpp', '.hpp', '.swift',
|
|
166
|
+
'.vue', '.svelte', '.astro', '.lock', '.csv',
|
|
167
|
+
]
|
|
168
|
+
|
|
169
|
+
const BINARY_EXTENSIONS: readonly string[] = [
|
|
170
|
+
'.png', '.jpg', '.jpeg', '.gif', '.webp', '.avif', '.bmp', '.ico', '.icns', '.tiff',
|
|
171
|
+
'.mp3', '.mp4', '.wav', '.ogg', '.webm', '.mov', '.avi',
|
|
172
|
+
'.woff', '.woff2', '.ttf', '.otf', '.eot',
|
|
173
|
+
'.pdf', '.zip', '.gz', '.tgz', '.bz2', '.xz', '.7z', '.rar', '.tar',
|
|
174
|
+
'.wasm', '.node', '.so', '.dylib', '.dll', '.exe', '.bin', '.class', '.jar',
|
|
175
|
+
'.db', '.sqlite', '.sqlite3',
|
|
176
|
+
]
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* The binary verdict a path already carries, or `null` for a file that has to be probed.
|
|
180
|
+
*
|
|
181
|
+
* The three executors that walk a tree — the library-local helper, the publisher and the connector
|
|
182
|
+
* SDK — must answer the same verdict for the same file, and a probe alone does not: a small `.ico`
|
|
183
|
+
* with no NUL in its first bytes reads as text, so a census run on a laptop and the same census
|
|
184
|
+
* run in the slot disagreed about the same repository. The tail is asked first and the probe only
|
|
185
|
+
* where the tail says nothing, which is also why the probe is affordable at census scale — the
|
|
186
|
+
* extensions above are the bulk of any repository.
|
|
187
|
+
*
|
|
188
|
+
* The extension is taken exactly the way `path.extname` takes it, because two of the three callers
|
|
189
|
+
* used to: the last dot of the last SEGMENT, and nothing for a name with no dot or for a dotfile.
|
|
190
|
+
*/
|
|
191
|
+
export const binaryByExtension = (path: string): boolean | null => {
|
|
192
|
+
const base = segmentsOf(path).pop() ?? path
|
|
193
|
+
const dot = base.lastIndexOf('.')
|
|
194
|
+
if (dot < 1) return null
|
|
195
|
+
const ext = base.slice(dot).toLowerCase()
|
|
196
|
+
|
|
197
|
+
return TEXT_EXTENSIONS.includes(ext) ? false : BINARY_EXTENSIONS.includes(ext) ? true : null
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/**
|
|
201
|
+
* How usable a file's head is as evidence.
|
|
202
|
+
*
|
|
203
|
+
* The printable ratio over the sampled head, and nothing cleverer: the question is only whether a
|
|
204
|
+
* model can read it. A minified bundle is printable and useless, so a second rule catches the
|
|
205
|
+
* shape that gives it away — very long lines with almost no whitespace.
|
|
206
|
+
*/
|
|
207
|
+
export const entropyClassOf = (head: string): EntropyClass => {
|
|
208
|
+
if (head.length < 1) return EntropyClass.Text
|
|
209
|
+
|
|
210
|
+
let printable = 0
|
|
211
|
+
let whitespace = 0
|
|
212
|
+
for (const char of head) {
|
|
213
|
+
const code = char.codePointAt(0) ?? 0
|
|
214
|
+
if (code === 9 || code === 10 || code === 13 || code === 32) {
|
|
215
|
+
++whitespace
|
|
216
|
+
++printable
|
|
217
|
+
} else if (code >= 32 && code !== 127) {
|
|
218
|
+
++printable
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const ratio = printable / head.length
|
|
223
|
+
if (ratio < 0.85) return EntropyClass.Opaque
|
|
224
|
+
// Prose, code and markup all break lines and indent. A body that does neither is minified,
|
|
225
|
+
// encoded or packed — printable, and not something a model can reason over.
|
|
226
|
+
if (whitespace / head.length < 0.05) return EntropyClass.Dense
|
|
227
|
+
|
|
228
|
+
return EntropyClass.Text
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
/** Path segments and name fragments that mark bulk data — an export, not the app's own data. */
|
|
232
|
+
const BULK_HINTS = ['dump', 'dumps', 'export', 'exports', 'backup', 'backups', 'snapshot', 'archive']
|
|
233
|
+
|
|
234
|
+
/** Path segments that mark seed data — what the application needs in order to make sense. */
|
|
235
|
+
const SEED_HINTS = ['seed', 'seeds', 'fixture', 'fixtures', 'sample', 'samples', 'demo-data']
|
|
236
|
+
|
|
237
|
+
const matchesHint = (path: string, hints: string[]): boolean => {
|
|
238
|
+
const lower = path.toLowerCase()
|
|
239
|
+
if (hasSegment(lower, hints)) return true
|
|
240
|
+
const base = segmentsOf(lower).pop() ?? lower
|
|
241
|
+
|
|
242
|
+
return hints.some(hint => base.includes(hint))
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
export const isBulkPath = (path: string): boolean => matchesHint(path, BULK_HINTS)
|
|
246
|
+
|
|
247
|
+
export const isSeedPath = (path: string): boolean => matchesHint(path, SEED_HINTS)
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* How much work re-implementing a story is, as a multiplier on the per-story price band.
|
|
251
|
+
*
|
|
252
|
+
* Derived from what the extraction found, never asked of a model: a story backed by a handful of
|
|
253
|
+
* proofs and no algorithm is ordinary CRUD, one that carries described algorithms is business
|
|
254
|
+
* logic somebody has to reproduce. Two runs over the same extraction therefore price identically,
|
|
255
|
+
* which is the point — a band that moved between two viewings of the same screen would be noise.
|
|
256
|
+
*/
|
|
257
|
+
export const storyComplexity = (proof: Pick<StoryProof, 'proofs' | 'algorithms'>): number => {
|
|
258
|
+
const proofs = proof.proofs?.length ?? 0
|
|
259
|
+
const algorithms = proof.algorithms?.length ?? 0
|
|
260
|
+
|
|
261
|
+
if (algorithms > 1 || proofs > 8) return 2
|
|
262
|
+
if (algorithms > 0 || proofs > 3) return 1.5
|
|
263
|
+
|
|
264
|
+
return 1
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* The stage after this one.
|
|
269
|
+
*
|
|
270
|
+
* The last stage answers with itself: there is nothing after implementation, and returning
|
|
271
|
+
* `undefined` would only move the same check to every call site.
|
|
272
|
+
*/
|
|
273
|
+
export const stageAfter = (stage: ConversionStage): ConversionStage => {
|
|
274
|
+
const at = CONVERSION_STAGE_ORDER.indexOf(stage)
|
|
275
|
+
|
|
276
|
+
return CONVERSION_STAGE_ORDER[at + 1] ?? stage
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/**
|
|
280
|
+
* The decision that ADVANCES out of a stage.
|
|
281
|
+
*
|
|
282
|
+
* Implementation's is {@link ConversionDecision.Leave}, because a finished conversion has nothing
|
|
283
|
+
* further to run and leaving it as it stands is the ordinary outcome rather than an abandonment.
|
|
284
|
+
*/
|
|
285
|
+
export const decisionFor = (stage: ConversionStage): ConversionDecision => {
|
|
286
|
+
switch (stage) {
|
|
287
|
+
case ConversionStage.Intake: return ConversionDecision.Analyze
|
|
288
|
+
case ConversionStage.Analysis: return ConversionDecision.Extract
|
|
289
|
+
case ConversionStage.Extraction: return ConversionDecision.Implement
|
|
290
|
+
default: return ConversionDecision.Leave
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Whether a conversion at `from` may enter `to`.
|
|
296
|
+
*
|
|
297
|
+
* The same stage is legal — that is a retry. The next one is legal. Nothing else is: every stage
|
|
298
|
+
* reads the documents the stage before it wrote, so skipping one means running against documents
|
|
299
|
+
* that were never produced, and going back means overwriting the record a later stage is built on.
|
|
300
|
+
*/
|
|
301
|
+
export const canEnter = (from: ConversionStage, to: ConversionStage): boolean => {
|
|
302
|
+
const at = CONVERSION_STAGE_ORDER.indexOf(from)
|
|
303
|
+
const next = CONVERSION_STAGE_ORDER.indexOf(to)
|
|
304
|
+
if (at < 0 || next < 0) return false
|
|
305
|
+
|
|
306
|
+
return next === at || next === at + 1
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
/** The size of the rendered origin card, so a composer can trim before it exceeds its ceiling. */
|
|
310
|
+
export const originCardChars = (card: OriginCard): number => [
|
|
311
|
+
card.stack as string,
|
|
312
|
+
card.case as ArchitectureCase as string,
|
|
313
|
+
card.purpose,
|
|
314
|
+
...card.packages,
|
|
315
|
+
...card.entities,
|
|
316
|
+
...card.flows,
|
|
317
|
+
...card.conventions,
|
|
318
|
+
].reduce((total, part) => total + (part?.length ?? 0), 0)
|
|
319
|
+
|
|
320
|
+
/** Whether a rendered card still fits the budget every coder prompt carries it in. */
|
|
321
|
+
export const originCardFits = (card: OriginCard): boolean =>
|
|
322
|
+
originCardChars(card) <= ORIGIN_CARD_MAX_CHARS
|
|
323
|
+
|
|
324
|
+
/** Whether a target-relative path names the origin tree, or something inside it. */
|
|
325
|
+
export const isOriginPath = (path: string): boolean =>
|
|
326
|
+
path === CONVERTED_ORIGIN_DIR || path.startsWith(`${CONVERTED_ORIGIN_DIR}/`)
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* A path inside the origin tree, from a path relative to the origin's own root.
|
|
330
|
+
*
|
|
331
|
+
* Idempotent: a path already under the origin comes back unchanged, so a caller that has lost
|
|
332
|
+
* track of which side of the move it holds cannot produce `__viable_converted/__viable_converted/`.
|
|
333
|
+
*/
|
|
334
|
+
export const originPath = (relative: string): string => {
|
|
335
|
+
const path = relative.replace(/^\/+/, '')
|
|
336
|
+
if (path === '') return CONVERTED_ORIGIN_DIR
|
|
337
|
+
if (isOriginPath(path)) return path
|
|
338
|
+
|
|
339
|
+
return `${CONVERTED_ORIGIN_DIR}/${path}`
|
|
340
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export * from './consts.js'
|
|
2
|
+
export * from './schemas.js'
|
|
3
|
+
export * from './helpers.js'
|
|
4
|
+
export type * from './types.js'
|
|
5
|
+
/**
|
|
6
|
+
* Declared beside the slot command that produces it and re-exported here, because the census is
|
|
7
|
+
* the only thing that reads a whole tree of them: one declaration, reachable from both barrels
|
|
8
|
+
* under the name every appendix uses. Two copies would drift the moment one gained a field.
|
|
9
|
+
*/
|
|
10
|
+
export type { FileStat } from '../slot/types.js'
|