@chrok/braid 0.1.0 → 0.1.2

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/CHANGELOG.md CHANGED
@@ -2,7 +2,26 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
- No changes yet.
5
+ ## 0.1.2 — 2026-09-27
6
+
7
+ - Make Pi depend on the exact `@chrok/braid` version instead of bundling core.
8
+ Export shared model-adapter helpers from the existing root entry point.
9
+ - Use one npm workspace lockfile and a development-only local core link; test
10
+ Pi-only installation against the unpublished core tarball outside the checkout.
11
+ - Wait for core registry metadata and tarball availability before publishing Pi.
12
+
13
+ ## 0.1.1 — 2026-09-27
14
+
15
+ - Validate the Pi integration against Pi 0.87.1; update GitHub Actions and tsx.
16
+ - Group routine dependency updates and reserve Node/TypeScript major upgrades
17
+ for deliberate compatibility changes across both packages.
18
+ - Clarify Pi tool and context guidance for parallel implementation and merge
19
+ nodes; describe read-only filesystem access by the node's assigned workspace
20
+ instead of assuming its directory is outside Git.
21
+ - Trim OpenAI-compatible base URL trailing slashes in linear time, avoiding
22
+ excessive regular-expression backtracking on long internal slash sequences.
23
+ - Protect the main branch and version tags; document repository governance,
24
+ CodeQL checks, Actions restrictions, and immutable releases.
6
25
 
7
26
  ## 0.1.0 — 2026-09-27
8
27
 
package/CONTRIBUTING.md CHANGED
@@ -12,13 +12,20 @@ Use Node.js 22.19+ and npm. From a fresh checkout:
12
12
  git clone https://github.com/Epsirom/braid.git
13
13
  cd braid
14
14
  npm ci
15
- npm ci --prefix integrations/pi
16
15
  npm run verify
17
16
  ```
18
17
 
19
- There are two packages and two lockfiles. The core has no runtime dependencies;
20
- Pi's dependencies belong in `integrations/pi`. Update and commit the corresponding
21
- lockfile when changing a dependency. Do not commit generated `dist` directories,
18
+ The root npm workspace lockfile covers both packages. A development-only
19
+ `@chrok/braid: file:.` dependency links the core checkout into `node_modules`;
20
+ Pi's manifest still declares the exact release version. This lets CI test a
21
+ new core before it is published. `check:pi`, `test:pi`, and `build:pi` rebuild
22
+ core so package imports resolve current JavaScript and declarations. Consumers
23
+ installing either published package do not install this development dependency.
24
+ Use `npm install --workspace @chrok/pi-braid <dependency>` for Pi dependency
25
+ updates; do not create a separate lockfile in `integrations/pi`.
26
+
27
+ The core has no runtime dependencies. Pi's dependencies belong in its workspace
28
+ manifest. Update and commit the root lockfile when changing a dependency. Do not commit generated `dist` directories,
22
29
  tarballs, credentials, or provider output containing private data.
23
30
 
24
31
  `verify` type-checks both packages, runs deterministic tests and offline examples,
@@ -29,6 +36,12 @@ calls a model. `npm test` is the fast core-only loop; `npm run test:pi` tests Pi
29
36
 
30
37
  ## Changes and reviews
31
38
 
39
+ Submit changes to `main` through a pull request, including maintainer changes.
40
+ Keep the branch up to date, pass the required CI and CodeQL checks, and resolve
41
+ review conversations before squash merging. See the
42
+ [repository policies](docs/repository-settings.md) for the complete settings and
43
+ the current single-maintainer review policy.
44
+
32
45
  - Keep the TypeScript strict checks passing. Follow nearby code and the
33
46
  repository's two-space formatting; use explicit public types.
34
47
  - For behavior changes, add a regression test that fails before the change.
package/README.md CHANGED
@@ -73,7 +73,7 @@ before running a custom adapter against a repository.
73
73
 
74
74
  ## Install in Pi
75
75
 
76
- With Pi 0.85.1 and Node.js 22.19+:
76
+ With Pi 0.87.1 and Node.js 22.19+:
77
77
 
78
78
  ```sh
79
79
  pi install npm:@chrok/pi-braid
package/ROADMAP.md CHANGED
@@ -18,6 +18,10 @@ Published versions are listed in [GitHub releases](https://github.com/Epsirom/br
18
18
 
19
19
  ## Next candidates
20
20
 
21
+ - Migrate both packages from TypeScript 5 to 7 in one dedicated change. Explicitly
22
+ load Node types, review compiler default changes, and validate public declaration
23
+ consumption, package builds, and the complete Node/platform matrix. Keep Node
24
+ declarations on 22.x while Node 22 remains the minimum supported runtime.
21
25
  - Measure real applications before changing scheduler data structures.
22
26
  - Discuss optional per-run node/output limits and host-wide admission controls.
23
27
  - Define budget semantics that account for missing usage and in-flight calls
@@ -65,7 +65,11 @@ function parseCompletion(value) {
65
65
  export function createOpenAICompatibleRunner(options = {}) {
66
66
  const { apiKey, defaultModel } = options;
67
67
  const fetchImpl = options.fetch ?? globalThis.fetch;
68
- const url = `${(options.baseURL ?? "https://api.openai.com/v1").replace(/\/+$/, "")}/chat/completions`;
68
+ const baseURL = options.baseURL ?? "https://api.openai.com/v1";
69
+ let end = baseURL.length;
70
+ while (end > 0 && baseURL[end - 1] === "/")
71
+ end--;
72
+ const url = `${baseURL.slice(0, end)}/chat/completions`;
69
73
  return async (request) => {
70
74
  const model = request.model ?? defaultModel;
71
75
  if (!model)
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  export { braid } from "./runtime.js";
2
2
  export { validateGraph, GraphValidationError } from "./validate.js";
3
3
  export type { BraidInput, BraidNode, BraidOptions, BraidResult, DecisionNode, Edge, ExecuteNode, ExecutionContext, ExecutionError, ExecutionEvent, ModelRequest, ModelResponse, ModelRunner, MergeNode, MergeDisposition, MergeSource, GitPreview, SourceCheckoutStatus, NodeWorkspace, GitResult, NodeOutput, NodeResult, NodeStatus, PredecessorOutput, TokenUsage, } from "./types.js";
4
+ export { formatBudgetReminder } from "./budgets.js";
5
+ export { gitToolDefinition, finishMergeToolDefinition, mergeInstructions, parseGitToolArguments, parseFinishMergeArguments, } from "./merge-tools.js";
package/dist/index.js CHANGED
@@ -1,2 +1,5 @@
1
1
  export { braid } from "./runtime.js";
2
2
  export { validateGraph, GraphValidationError } from "./validate.js";
3
+ // Shared helpers for model adapters, including the Pi integration.
4
+ export { formatBudgetReminder } from "./budgets.js";
5
+ export { gitToolDefinition, finishMergeToolDefinition, mergeInstructions, parseGitToolArguments, parseFinishMergeArguments, } from "./merge-tools.js";
@@ -3,7 +3,7 @@
3
3
  | Surface | Supported / tested contract |
4
4
  | --- | --- |
5
5
  | Core runtime | Node.js 22+, ESM imports, TypeScript declarations, no runtime dependencies |
6
- | Pi package | Node.js 22.19+, Pi 0.85.1 is the pinned validation target |
6
+ | Pi package | Node.js 22.19+, Pi 0.87.1 is the pinned validation target |
7
7
  | CI | Core minimum Node 22.0; both packages on Node 22.19 and 24 on Linux, macOS, Windows |
8
8
  | OpenAI-compatible runner | Chat Completions text and function-tool calls; decisions and merge nodes require tool calling |
9
9
  | Browsers / CommonJS | No supported browser build or CommonJS entry point in 0.1 |
@@ -14,11 +14,18 @@ that every provider advertising OpenAI compatibility supports its tool schema.
14
14
  Run a small opt-in live test with your chosen provider before relying on it.
15
15
 
16
16
  Pi's upstream packaging guide requires `*` peer dependencies for packages the
17
- host provides. Braid follows that convention and pins dev dependencies to 0.85.1.
17
+ host provides. Braid follows that convention and pins dev dependencies to 0.87.1.
18
18
  The wildcard is a loader/distribution convention, **not a claim that every Pi
19
19
  version works**. Test the whole Pi suite before updating the supported target.
20
- The Pi npm package compiles and includes the same core source as the matching
21
- core release, so it does not need another installed copy of Braid or a checkout.
20
+ The offline host compatibility test loads the extension into a real Pi session
21
+ with an in-memory model provider. It checks worker prompt/tool normalization and
22
+ exactly one automatic continuation when a job finishes during `agent_settled`.
23
+ This covers the Pi 0.86/0.87 transcript and settling changes without provider
24
+ credentials or network model calls. Version 0.1.0 was originally validated with
25
+ Pi 0.85.1; the current checkout's pinned validation target is 0.87.1.
26
+ The Pi npm package declares an exact dependency on the matching `@chrok/braid`
27
+ release. npm installs the core automatically; Pi does not bundle another copy of
28
+ its runtime and does not need a source checkout.
22
29
 
23
30
  Git must be installed for workspace execution inside a Git checkout. Non-Git
24
31
  text-only runs do not require Git workspace management.
@@ -30,8 +37,13 @@ preserve documented behavior; breaking API or semantic changes require a minor
30
37
  version bump, a changelog entry, and migration guidance. New optional fields or
31
38
  fixes that restore the documented contract may ship in a patch.
32
39
 
33
- Supported core entry points are `@chrok/braid` and `@chrok/braid/adapters/openai`. Internal
34
- files and Pi helper classes are not stable public APIs. Documented result/error
40
+ Supported core entry points are `@chrok/braid` and `@chrok/braid/adapters/openai`.
41
+ The root `@chrok/braid` entry point also exports adapter helpers:
42
+ `formatBudgetReminder`, `gitToolDefinition`, `finishMergeToolDefinition`,
43
+ `mergeInstructions`, `parseGitToolArguments`, and `parseFinishMergeArguments`.
44
+ These helpers share the core's compatibility policy; Git workspace implementation
45
+ classes remain internal. Internal files and Pi helper classes are not stable
46
+ public APIs. Documented result/error
35
47
  fields, routing behavior, `ModelRunner`, and existing event meanings are part of
36
48
  the public contract. Consumers should ignore new diagnostic fields and provide a
37
49
  fallback for new event types; event sequence numbers order events within a run,
package/docs/releasing.md CHANGED
@@ -1,16 +1,23 @@
1
1
  # Releasing
2
2
 
3
3
  Core and Pi are separate public npm packages built from one commit. Both use the
4
- same version. The core has no runtime dependencies. Pi bundles compiled core
5
- source so its installed extension never reaches outside its own package.
4
+ same version. The core has no runtime dependencies. Pi declares an exact
5
+ `@chrok/braid` dependency and includes only its own compiled integration code.
6
6
 
7
7
  ## Prepare a release
8
8
 
9
- 1. Update both `package.json` versions and both lockfiles. Use a minor version
9
+ Version tags (`v*`) cannot be moved or deleted. New GitHub releases are immutable:
10
+ prepare a draft and attach any assets before publishing. Published tag/asset
11
+ corrections require a new version. See [repository settings](repository-settings.md).
12
+
13
+ 1. Update both `package.json` versions, Pi's exact `@chrok/braid` dependency,
14
+ and the root workspace lockfile (`npm install --package-lock-only`). Use a minor version
10
15
  for breaking 0.x changes, and describe migrations in the changelog.
11
- 2. Run `npm ci`, `npm ci --prefix integrations/pi`, and `npm run verify`.
16
+ 2. Run `npm ci` and `npm run verify` from the repository root.
12
17
  The package check verifies clean builds, public ESM imports, declarations,
13
18
  licenses, and Pi registration in a temporary consumer outside the checkout.
19
+ A temporary local registry serves the unpublished core tarball; installing
20
+ only the Pi tarball must fetch core transitively through its version dependency.
14
21
  3. Update the changelog and supported Pi version. Commit and review the changes;
15
22
  require the CI matrix to pass before tagging that commit `vX.Y.Z`.
16
23
  4. Inspect `npm pack --dry-run` and `npm pack --dry-run` from `integrations/pi`.
@@ -18,6 +25,11 @@ source so its installed extension never reaches outside its own package.
18
25
 
19
26
  ## First publication
20
27
 
28
+ Enable two-factor authentication in the npm account's web settings before the
29
+ first publish. An emailed login code does not replace enrolling a security key
30
+ or passkey for publishing. Complete credential enrollment yourself and keep
31
+ recovery codes private.
32
+
21
33
  Log in locally with `npm login --registry=https://registry.npmjs.org`; confirm the
22
34
  account with `npm whoami`. Publish the core with `npm publish --access public`,
23
35
  then run `npm publish --access public` from `integrations/pi`. Complete npm's
@@ -25,7 +37,12 @@ interactive account/2FA checks if requested. Never put credentials in source,
25
37
  issues, shell history, or CI logs. An npm registration alone does not guarantee
26
38
  ownership of a previously used package name.
27
39
 
28
- After publication, install the registry versions in a fresh project and verify
40
+ New packages may temporarily return `E404` after a successful publish while npm
41
+ runs its [publish-time scan](https://github.blog/changelog/2026-07-28-npm-publish-time-malware-scanning-and-dual-use-metadata/).
42
+ Allow time for the exact versions to become available through `npm view`; do not
43
+ republish or bump versions just to work around this delay.
44
+
45
+ After availability is confirmed, install the registry versions in a fresh project and verify
29
46
  both exported core entry points and the Pi extension. Add the actual publication
30
47
  date to the changelog and create the corresponding GitHub release.
31
48
 
@@ -39,9 +56,22 @@ For **each** package, configure an npm GitHub trusted publisher:
39
56
  - Environment: leave blank (this workflow does not declare one)
40
57
  - Allow direct `npm publish`
41
58
 
59
+ With npm 11.20 or later, the equivalent CLI setup is:
60
+
61
+ ```sh
62
+ npm trust github @chrok/braid --file release.yml --repo Epsirom/braid --allow-publish
63
+ npm trust github @chrok/pi-braid --file release.yml --repo Epsirom/braid --allow-publish
64
+ npm trust list @chrok/braid
65
+ npm trust list @chrok/pi-braid
66
+ ```
67
+
42
68
  Publishing a non-prerelease GitHub release triggers `.github/workflows/release.yml`.
43
69
  It validates the tag/version relationship, repeats all checks, and publishes
44
- core then Pi using short-lived OIDC credentials. It does not require `NPM_TOKEN`.
70
+ core then Pi using short-lived OIDC credentials. After each publish (or retry
71
+ of an existing version), it waits for matching version/commit metadata and a
72
+ successful tarball download. Pi is not published until core is available. npm
73
+ processing is polled every 15 seconds for up to 10 minutes; a timeout fails the
74
+ workflow with retry instructions. It does not require `NPM_TOKEN`.
45
75
  The workflow installs npm 11 and uses Node 24. See
46
76
  [npm's trusted publishing documentation](https://docs.npmjs.com/trusted-publishers/).
47
77
 
@@ -0,0 +1,83 @@
1
+ # Repository settings
2
+
3
+ The live [GitHub rulesets](https://github.com/Epsirom/braid/rules) enforce these
4
+ policies. JSON files in [.github/rulesets](../.github/rulesets) are reviewable
5
+ copies of the API payloads; committing a change to them does not apply it to
6
+ GitHub automatically. Update the existing ruleset in Settings or through the
7
+ REST API after reviewing a policy change, then verify the live settings.
8
+
9
+ ## Main branch
10
+
11
+ [Protect main](https://github.com/Epsirom/braid/rules/24072177) applies to `main`,
12
+ including administrators, with no bypass actors:
13
+
14
+ - Changes must go through a pull request. Direct pushes, force pushes, and
15
+ branch deletion are blocked.
16
+ - All review conversations must be resolved. New commits dismiss previous
17
+ approvals.
18
+ - The branch must be up to date and all seven CI checks must pass: `core-minimum`
19
+ and `verify` on Ubuntu, macOS, and Windows with Node 22.19.0 and 24. Checks must
20
+ originate from the GitHub Actions app.
21
+ - CodeQL must supply analysis results. Code scanning errors and new security
22
+ findings rated high or critical block merging.
23
+ - Squash is the only merge method, keeping a linear history. The squash commit
24
+ uses the PR title and description.
25
+
26
+ There is currently one maintainer with write access. Required approval count is
27
+ therefore zero: GitHub does not allow authors to approve their own PRs.
28
+ [CODEOWNERS](../.github/CODEOWNERS) requests maintainer review for contributions,
29
+ but code-owner approval and approval of the last push are not mandatory. When a
30
+ second maintainer joins, require at least one approving review and consider
31
+ requiring code-owner and last-push approval. CI and PR requirements apply to the
32
+ current maintainer as well.
33
+
34
+ Automatic merge is available when explicitly enabled for a PR; it still waits
35
+ for the rules above. GitHub offers an Update branch button and deletes merged
36
+ head branches automatically. Do not bypass a failing check to merge a change.
37
+
38
+ ## Releases
39
+
40
+ [Protect version tags](https://github.com/Epsirom/braid/rules/24072178) prevents
41
+ updates and deletion of `v*` tags, with no bypass actors. New version tags can
42
+ still be created by maintainers.
43
+
44
+ Immutable releases are enabled for future releases. Prepare a draft and upload
45
+ any assets before publishing; the release tag and assets become immutable when
46
+ published. This setting does not retroactively make existing releases immutable.
47
+ Use a new version for a correction. See [the release guide](releasing.md).
48
+
49
+ ## Actions and security
50
+
51
+ - Actions use read-only `GITHUB_TOKEN` permissions by default and cannot create
52
+ or approve PRs through that token. Individual workflows request only their
53
+ needed permissions; the release job uses `id-token: write` for npm OIDC.
54
+ - External actions and reusable workflows are limited to GitHub-owned
55
+ repositories; local actions remain allowed. External actions must be pinned
56
+ to full commit SHAs. Review and explicitly allow any future third-party action
57
+ before using it.
58
+ - Workflows from all external fork contributors require maintainer approval
59
+ before running. Inspect workflow and code changes before approving a run.
60
+ - CodeQL default setup scans GitHub Actions and JavaScript/TypeScript with the
61
+ default query suite and remote threat model, including its weekly schedule.
62
+ - Dependabot alerts/security updates, secret scanning, secret push protection,
63
+ and private vulnerability reporting are enabled. Dependency updates remain
64
+ configured in [.github/dependabot.yml](../.github/dependabot.yml).
65
+
66
+ These are repository settings, not organization-wide changes. Neither commit
67
+ sign-off nor a CLA is required for contributions.
68
+
69
+ ## Dependency maintenance
70
+
71
+ Dependabot checks both npm workspace manifests through the root lockfile weekly.
72
+ The internal `@chrok/braid` dependency is updated by the coordinated release process. Pi host packages stay in a separate
73
+ group because even 0.x minor releases can change extension contracts. Other npm
74
+ minor/patch updates are grouped; GitHub Actions updates are grouped monthly and
75
+ retain full commit SHA pins. Grouping does not enable automatic merging.
76
+
77
+ Keep `@types/node` on 22.x to match the oldest supported Node major. TypeScript
78
+ major upgrades require a coordinated migration of core and Pi, including the
79
+ standalone package/declaration checks; the current migration is tracked in the
80
+ [roadmap](../ROADMAP.md). Automatic major version updates for these two packages
81
+ are ignored until their compatibility policy changes. Minor/patch updates,
82
+ vulnerability alerts, and security-update configuration remain enabled. Review
83
+ any security fix that requires crossing an ignored major version manually.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrok/braid",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "license": "MIT",
5
5
  "description": "A small, framework-agnostic DAG runtime for isolated model invocations",
6
6
  "type": "module",
@@ -32,12 +32,12 @@
32
32
  "scripts": {
33
33
  "build": "node scripts/build.mjs",
34
34
  "check": "tsc --noEmit",
35
- "test": "tsx --test test/*.test.ts",
35
+ "test": "tsx --test test/*.test.ts test/*.test.mjs",
36
36
  "demo": "tsx examples/basic.ts",
37
- "check:pi": "npm --prefix integrations/pi run check",
38
- "test:pi": "npm --prefix integrations/pi test",
37
+ "check:pi": "npm run build && npm run check --workspace @chrok/pi-braid",
38
+ "test:pi": "npm run build && npm test --workspace @chrok/pi-braid",
39
39
  "prepack": "npm run build",
40
- "build:pi": "npm --prefix integrations/pi run build",
40
+ "build:pi": "npm run build --workspace @chrok/pi-braid",
41
41
  "test:package": "node scripts/package-smoke.mjs",
42
42
  "verify": "npm run check && npm test && npm run check:pi && npm run test:pi && npm run examples && npm run test:package",
43
43
  "examples": "tsx examples/basic.ts && tsx examples/code-review.ts && tsx examples/failure-handling.ts && tsx examples/custom-runner.ts",
@@ -47,8 +47,9 @@
47
47
  },
48
48
  "devDependencies": {
49
49
  "@types/node": "^22.0.0",
50
- "tsx": "^4.0.0",
51
- "typescript": "^5.0.0"
50
+ "tsx": "^4.23.15",
51
+ "typescript": "^5.0.0",
52
+ "@chrok/braid": "file:."
52
53
  },
53
54
  "repository": {
54
55
  "type": "git",
@@ -68,5 +69,8 @@
68
69
  "publishConfig": {
69
70
  "access": "public",
70
71
  "registry": "https://registry.npmjs.org"
71
- }
72
+ },
73
+ "workspaces": [
74
+ "integrations/pi"
75
+ ]
72
76
  }