@chrok/pi-braid 0.1.0 → 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/README.md CHANGED
@@ -90,7 +90,7 @@ only the current source IDs and diagnoses missing, duplicate or unexpected IDs.
90
90
 
91
91
  ## Install from npm
92
92
 
93
- Requires Node.js 22.19+ and Pi 0.85.1 (the tested version):
93
+ Requires Node.js 22.19+ and Pi 0.87.1 (the tested version):
94
94
 
95
95
  ```sh
96
96
  pi install npm:@chrok/pi-braid
@@ -100,7 +100,7 @@ Add `-l` for a project-local installation. Run `/reload` after installation.
100
100
  The package includes compiled Braid core code from the matching release; it does
101
101
  not depend on a source checkout. Pi supplies its core peer packages at runtime.
102
102
  Their wildcard ranges follow Pi's packaging convention, not universal version
103
- compatibility. Development and CI pin Pi 0.85.1.
103
+ compatibility. Development and CI pin Pi 0.87.1.
104
104
 
105
105
  ## Install this local checkout in Pi
106
106
 
@@ -50,9 +50,9 @@ const BRAID_FILESYSTEM_GUIDANCE = "In a Git repository, execute and decision nod
50
50
  "Inspect braid_status for integration outcomes and recovery checkpoint refs, then run tests in the parent. Avoid concurrent parent edits while a merge agent owns the source checkout.";
51
51
  const BRAID_USAGE_GUIDANCE = [
52
52
  "Braid is a proactive execution primitive, not only a user-requested command.",
53
- "Selection rule: for a code review, bug investigation, design comparison, test-planning request, or change spanning multiple files, call braid FIRST when two or more concerns can be analyzed independently. Do this without waiting for the user to say Braid; do not read everything in the parent and then decide whether to delegate.",
53
+ "Selection rule: for a code review, bug investigation, design comparison, test-planning request, or change spanning multiple files, call braid FIRST when two or more concerns can be handled independently. Nodes can analyze the project and implement changes in isolated Git worktrees. Do this without waiting for the user to say Braid; do not read everything in the parent and then decide whether to delegate.",
54
54
  BRAID_FILESYSTEM_GUIDANCE,
55
- "When Braid fits, construct and submit the complete DAG in one call: use parallel execute nodes for independent concerns and a final execute node to synthesize their outputs. The tool returns a jobId immediately. Continue independent work or finish your turn while it runs; do not poll repeatedly. A completion reminder will resume you. Use braid_status with the jobId to retrieve terminal outputs before relying on them.",
55
+ "When Braid fits, construct and submit the complete DAG in one call: use parallel execute nodes for independent analysis or implementation, execute nodes to synthesize findings, and merge nodes to integrate file changes. The tool returns a jobId immediately. Continue independent work or finish your turn while it runs; do not poll repeatedly. A completion reminder will resume you. Use braid_status with the jobId to retrieve terminal outputs before relying on them.",
56
56
  "Do not use braid for a simple one-step answer, a trivial direct edit, shell work, or when decomposition adds no value. The parent reviews results, runs tests, and executes shell commands after Braid completes.",
57
57
  ].join("\n");
58
58
  export function createBraidTools(jobs) {
@@ -69,10 +69,10 @@ export function createBraidTools(jobs) {
69
69
  "Do not use it for a simple one-step answer or trivial direct edit. " +
70
70
  "Use braid_status(jobId) for progress and results, or braid_cancel(jobId) to stop it. A completion reminder resumes the agent if idle; do independent work or end your turn instead of polling. Humans can open /braid for the live flow panel. " +
71
71
  "Read result.status: failed graphs can still return successful terminal outputs.",
72
- promptSnippet: "Use FIRST for nontrivial code review/debug/design work; parallelize independent analysis and synthesize",
72
+ promptSnippet: "Use FIRST for nontrivial code review/debug/design/implementation work; parallelize analysis or edits in isolated Git worktrees and use merge nodes to integrate changes",
73
73
  promptGuidelines: [
74
- "Call braid before direct repository inspection when a code task has two or more separable review, debugging, design, or test-planning concerns; the Braid nodes can inspect the project and edit isolated Git worktrees.",
75
- "Use parallel execute nodes for independent concerns and a final synthesis node. The user does not need to mention Braid or design the graph.",
74
+ "Call braid before direct repository inspection when a code task has two or more separable review, debugging, design, test-planning, or implementation concerns; the Braid nodes can inspect the project and edit isolated Git worktrees.",
75
+ "Use parallel execute nodes for independent analysis or implementation, execute nodes to synthesize findings, and merge nodes to integrate file changes. The user does not need to mention Braid or design the graph.",
76
76
  "Do not use braid for simple one-step answers or trivial direct edits. Keep shell commands and test execution in the parent; use merge nodes for integration.",
77
77
  BRAID_FILESYSTEM_GUIDANCE,
78
78
  "Decision nodes additionally receive decide. Nodes cannot call recursive Braid.",
@@ -98,7 +98,7 @@ export function createPiRunner(registry, onUsageOrOptions, cwd = process.cwd())
98
98
  ? "You may write and edit files inside your own isolated Git worktree. Use workingDirectory as your cwd; do not write to sourceRoot or any other node's worktree. " +
99
99
  "Nodes start from the current core snapshot of tracked changes and non-ignored untracked files. After merge nodes, newly started workers see the updated source checkout. Inspect predecessor checkpoints with git show when their worktrees have been removed. " +
100
100
  "Describe your changes in your final answer. A merge agent will review your checkpoint and core will clean up the worktree. "
101
- : "This directory is not a Git working tree, so all tools are read-only; you cannot write or edit files. ") +
101
+ : "This node has no writable workspace assigned. Its filesystem tools are read-only; you cannot write or edit files. ") +
102
102
  mergeInstructions(request) +
103
103
  "You cannot run shell commands, run tests, or call arbitrary tools. " +
104
104
  (request.node.type === "merge" && workspace.mode === "read-only"
@@ -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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@chrok/pi-braid",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "Pi extension for Braid: background DAG jobs and a live flow panel",
6
6
  "type": "module",
@@ -13,9 +13,9 @@
13
13
  "@earendil-works/pi-tui": "*"
14
14
  },
15
15
  "devDependencies": {
16
- "@earendil-works/pi-ai": "0.85.1",
17
- "@earendil-works/pi-tui": "0.85.1",
18
- "@earendil-works/pi-coding-agent": "0.85.1",
16
+ "@earendil-works/pi-ai": "0.87.1",
17
+ "@earendil-works/pi-tui": "0.87.1",
18
+ "@earendil-works/pi-coding-agent": "0.87.1",
19
19
  "typescript": "^5.0.0",
20
20
  "tsx": "^4.0.0",
21
21
  "@types/node": "^22.0.0"