Repository navigation
Conversation
(import "@acme/flows/ir" [FlowIR]) resolves through the forma.exports
field of an installed package's package.json. A module may import only the
packages its own package declares, relative imports may not leave a
package, and package modules get location-independent pkg:<name>/<path>
identities, so binding identities and contractIds match across machines.
The compiler takes a host package table (ModuleCoreOptions.packages,
configureSession({ packages })); @formalang/ts/node builds one from
package.json files and node_modules and rejects two versions of one
package; the forma file commands use it. Packages may declare a prelude
for their own modules. Session loading no longer bootstraps a file
module's own forms as session descriptors, so a module form can use an
imported :ir type in sessions and the CLI.
RFC 0018 replaces RFC 0002's forma.toml and lockfile sketch: npm, pnpm,
or yarn install and lock packages.
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #103.
Summary
Forma modules can now import from packages, and RFC 0018 specifies how.
Decisions (RFC 0018)
forma.tomlsketch.formafield ofpackage.json.exportsmaps"."/"./sub"to files, and only those files can be imported from outside. An optionalpreludegives the package's own modules automatic imports.dependencies,peerDependencies,optionalDependencies, plusdevDependenciesfor the root).pkg:<name>/<path>, without the version. Binding identities, generated names, andcontractIds match across machines and stay the same across releases that don't change a definition. The root package's modules keep their file paths, so diagnostics stay clickable.module/undeclared-dependency,module/package-not-found,module/package-private(lists the exports),module/package-escape,module/specifier. From the host table:module/package-version-conflict,module/package-table.Implementation
@formalang/ts/modules):PackageTable,withPackages,pkg:IDs, and package preludes through the existing project-prelude mechanism.resolveModuleGraphacceptspackages. The resolver contract is unchanged: a bare specifier becomes./<export>from importerpkg:<name>/, sosourceModuleResolverworks as is.@formalang/ts/node):readNodePackages(entry)finds the nearestpackage.json, follows Forma dependencies throughnode_modules, and rejects version conflicts.nodeModuleResolverreads package files, andreadModuleGraphuses both.configureSession({ packages })and its JSON ABI schema. Theforma fileCLI configures the session from the Node table.formwhose:irtype was imported failed at load withunknown IR type. That affected Let a form produce an :ir type another module exports #103's feature in sessions and the CLI, not just packages. File modules are now left to the module graph.The language server doesn't resolve packages yet (RFC stage 2). Publishing the repository preludes as packages, so that Open Ontology can stop vendoring them, is stage 3.
Docs: RFC 0018,
docs/modules.md"Packages", RFC 0002 cross-links,docs/agents.md, sidebar. Changeset included.Tests
packages/ts/test/packages.test.ts:contractIdthrough a packagenode_modulescontractIdfrom two install locationspackages/host/test/packages.test.ts: a JSON ABI session with a package table, including an undeclared dependency, andforma file typecheck/interfaceagainst installed packages.pnpm checkpasses. No goldens changed.🤖 Generated with Claude Code
Open workspace in Conductor