junco / junco-agent
AGENTS.md1 starsChanged 33 days agoMITView on GitHub
Read README.md for setup and user-facing usage. This file describes the contracts to preserve when changing this repository. dist/, node_modules/, *.tsbuildinfo, and graphify-out/ are generated and ignored. Dependencies are locked by the workspace root's bun.lock. Install once at the junco workspace root, then run from packages/junco-agent:
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 35,266 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository8 other files it gives its agents.
- AGENTS.mdAGENTS.md
- crates/junco-policy/AGENTS.mdAGENTS.md
- crates/marsh/AGENTS.mdAGENTS.md
- update-dependenciesSkill
- graftSkill
- junco-graph-createSkill
- junco-graph-optimizerSkill
- junco-profile-optimizerSkill
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 2 are distinctive, and 1 is very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈2
Distinctive · estimate
This author's own choices. Worth a look.
1
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 3
Read README.md for setup and user-facing usage.
- Very specific: line 10
Keep changes scoped to the request and preserve unrelated local work.
- Distinctive: line 71
Verify the native default path only against a disposable dedicated Btrfs seed.
≈ “Common” is an estimate: at least 1 in 5 of the 45,344 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Agent guidance for junco-agent
Read README.md for setup and user-facing usage. This file describes the contracts to preserve when changing this repository.
Scope and compatibility
- This is a private ESM TypeScript library.
JuncoAgentextends Pi'sAgentHarnessunchanged as the conversation/control plane and adds a cooperative lifetime iterator over scheduling boundaries. It has no dataflow graph, persistence layer, capability checking, standalone agent CLI, native code, or Cargo manifest;bun run cli <seed>only launches Pi's CLI with thejunco-toolsextension. Graphs of agents live in the workspace root packagejunco. Never import from or depend on../junco-runtime. - Pins: Bun
1.3.14for package management and tests, TypeScript6.0.3, and every@earendil-works/*package at exactly0.80.6(pi-agent-corealso forced through the workspace root'soverrides). That is the Pi versionjunco-toolsdeclares as its peer and the version the patch targets. Supported runtime: Linux x86-64 with glibc and Node.js>=22.19.0. - Runtime dependencies are exactly
junco-tools(workspace:*, the workspace package at../junco-tools),pi-agent-core,pi-ai,pi-coding-agent(Pi's login-backedModelRuntime, also ajunco-toolspeer) andtypebox(theyieldschema). Never substitute a registry package or the old monorepo's tools package. - Keep changes scoped to the request and preserve unrelated local work. Unless explicitly authorized, do not push, publish, edit
../junco-toolsfrom here, or create or mount Btrfs volumes.
Source map
| Path | Responsibility |
src/agentic.ts | The Agentic contract: AgentHarnessApi, AgenticStatus, AgenticYieldReason, AgenticStep, AgenticOptions, AgenticConstructor. Types only. |
src/junco-agent.ts | JuncoAgent: run admission through the patch's per-run integration, pause recording and gating, the demand queue, status, abort, terminal close, the protected subclass hooks, and the create factory with its owned resources. |
src/index.ts | Public exports: the contract types, JuncoAgent, JuncoAgentError, AgenticRun, JuncoAgentCreateOptions, TaskAgentOptions, TaskPolicy, TaskFailurePolicy, SubagentObserver. Nothing else; YieldTool, TaskTool, AssignedTaskTool and their helpers and types are owned and exported by junco-tools. |
patches/@earendil-works%2Fpi-agent-core@0.80.6.patch | The one canonical Pi patch, registered here and by consumers (../junco) from their own roots. |
scripts/run-cli.sh | Bun script launcher: enter the caller's dedicated Btrfs seed, exec pinned Pi cli.js with the installed junco-tools extension, and forward Pi arguments. |
test/harness.ts | Offline scaffolding: scripted/nativeOptions (faux model, in-memory session, no tools), newAgent, gatedTool, countingTool. |
test/junco-agent.test.ts | Native fidelity against a raw harness, iterator ordering, pauses, abort, terminal close, the native limits, create ownership, and saved Pi login/error behavior. |
dist/, node_modules/, *.tsbuildinfo, and graphify-out/ are generated and ignored. Dependencies are locked by the workspace root's bun.lock.
Build and verification commands
Install once at the junco workspace root, then run from packages/junco-agent:
bun install --frozen-lockfile # at the workspace root
bun run build
bun run typecheck
bun run test- Build
junco-toolsfirst. If itsdist/ornative/junco_tools.linux-x64-gnu.nodeis missing, runbun run buildin../junco-tools, following its README. Do not change its Cargo configuration or backend from here. - The workspace links
junco-toolsto../junco-tools, so its compiled output and native addon are read from there. buildandtypecheckinvoke TypeScript directly.tsconfig.jsonincludes onlysrc/**/*.ts, so the tests are not type-checked.verbatimModuleSyntaxis on.
The Pi patch
- Change Pi only through
bun patch @earendil-works/pi-agent-core@0.80.6andbun patch --commit, then make the committed file a standardgit diffwitha//b/package-relative headers: Bun1.3.14writes machine-specific paths into deleted- and added-file headers, and its output is not portable until normalized. Deleted source maps keep header-only deletions, which Bun applies. - New files the patch adds live at the package root (
agentic-integration.js/.d.ts, exported as./agentic-integration). Bun1.3.14creates a new file's parent directory relative to the installing project instead of the package, with the file's mode, so a newdist/…file leaves an unusable emptydist/in every consumer that installs the patch fresh. - The patch adds only per-run integration and never changes behavior without it. Its surface: the
./agentic-integrationexport (AGENTIC_INTEGRATION_REVISIONand theAgentRunIntegrationobserver type); protectedcreateRunIntegration(kind), called once byprompt/skill/promptFromTemplateafter the busy guard and before their first await; protectedabortDependents(), started byabort()right after notifying the run's controller and joined afterwaitForIdleand before theabortevent; protectedflushPendingSessionWrites; and an optional lastintegrationargument ofrunAgentLoop. Uninstrumented calls keep their exact control flow and promises. Source maps are removed only for the edited modules. - Observer callbacks:
controllerafter the run'sAbortControlleris installed;beforeToolswith the complete assistant message before its batch executes;toolOutcomeright after each actualexecutepromise settles (argument validation, hooks and update listeners are not observed; a failure is rethrown unchanged);trackfor every started parallel worker and update emission, never awaited;afterTurnonly on the normal path afterturn_enddelivery, before the next turn is prepared (a returned promise gates the next request);abandonedwhen the low-level run rejects, before native failure reporting. OnlyafterTurnmay be asynchronous; none may throw. - Bump
AGENTIC_INTEGRATION_REVISIONtogether withREQUIRED_INTEGRATION_REVISIONinsrc/junco-agent.tswhenever the observer contract changes.
Lifetime invariants
JuncoAgentoverrides only the three run-starting methods (to scope admission and reject while a prompt is staged or after close), the mutating operations (to reject after close and track them),abort(), and the protected hooks. It never proxies, re-emits, wraps tools or providers, or replaces native arguments, results, errors or event order. Native getters andsystemPromptkeep native identity andthis.- Admission uses a stack of synchronous invocation scopes filled by
createRunIntegration; a call Pi rejects as busy fills none and publishes nothing, while every admitted run publishes exactly onesettledorfailedboundary — including abefore_agent_starthook that throws a busy-coded error, and missing skills or templates. - Pause reasons belong to their run and assistant message, keyed by tool call id, and are ordered by the batch's tool results at
afterTurn. Only tools created byjunco-tools'new YieldTool()(checked with itsisYieldTool, never by name) and errors satisfyingisMarshPolicyDenied(a code check, never message text) record reasons;tasknever pauses. An abandoned run discards its reasons; late sibling outcomes stay tracked for close but cannot publish a pause. - Demands are served strictly in order. A demand takes the oldest unread boundary; only with none does it resume the oldest consumed pause or start the staged prompt. Without a demand every gate stays shut.
abort()marks the currently admitted runs stopping, callssuper.abort()exactly once, then releases their gates and drops their unread pauses. It returns the native promise unchanged and never closes resources.- Terminal close is one shared operation: it rejects native run-starting and mutating calls from its first instant, starts native abort, the current run's private task-scope stop and
closeDependents()without awaiting any, releases every gate, joins all admitted operations and tracked work, then the abort, the task scope and the dependents, flushes session writes, and releases factory-owned resources exactly once. Failures aggregate in that order.abort()composes the same task-scope stop withabortDependents(), so a subclass skippingsupercannot leak task children. createloads the native addon only throughToolCollection.createwhentoolsis omitted, or through a nonempty MCP definition's connection: thejunco-toolsandjunco-mcproot imports load no addon, so concrete explicit tools never do. Both factories expandJuncoMcpToolssources in order before construction and record each connection as factory-owned; release closes them in reverse, then the collection, then the session repository; a collection's mux closes only on its final release. A suppliedcollectionis borrowed: the protected constructor is the single site that takes itslease(), and its policy must equal the requiredpolicy. It takes ownership only of what it creates. Provider/model ID strings resolve through Pi'sModelRuntime, optionally shared viamodels; require the selected provider's saved Pi credential and resolve/refresh it before allocating default sessions/tools. Never start an interactive login or fall back to Copilot CLI credentials: missing/unusable credentials must tell the user to run/loginin Pi.fromResolvedremains caller-authenticated.createSubagentsvalidates every option before creating a child, gives each child its ownMemorySessionRepo, and never shares a live MCP client: it reconnects the per-call snapshot of every recordedMcpSourceRegistrationand rebinds the selected tools bygetJuncoMcpToolIdentity, never by published name. Children inherit the parent's policy and actualToolCollection, each holding its owncollection.lease(); only the last release closes the collection and its mux. Children never receive the caller's hooks, subscriptions, transcript, node context, task scope, task policy, failure policy, subagent observer or assigned batch: anAssignedTaskTool.istool is replaced by a freshnew TaskTool(). ChildrencreateSubagentsreturns are caller-owned; only those a nativetaskadmission acquires belong to the admitting run'sTaskScope(src/tasks.ts), which starts them at admission, closes each before handling its outcome and joins all of them before the run settles, aborts or closes.- A
setTaskPolicypolicy runs inside everytasklaunch (never a retry/ignore decision), after input validation and before the host: its throw is a tool error, never a pause or a run failure. - Task reports are authenticated by native queued-entry id (
message_end), never by parsing message text; a fatal task failure is latched on the run and rethrown by the native drive (Pi isolates hook errors), and thebefore_run_endhook never throws or returns a follow-up. - Assigned-batch admission state lives on the agent, never the shared tool: one
#taskAdmittedflag, set only after the host fulfils and before handle-count checks, result serialization or hooks can fail, so no malformed receipt reopens the batch; a host rejection leaves it unset. Sequentialtaskexecution is what rules out overlapping launches.setTaskBatchrejects once it is set. SubagentObserver.acquiringruns before anycreateSubagentsallocation andacquiredper child after allocation, before the batch returns; a throw from either rejects the batch with every created child closed.- Cleanup aggregates (failed construction, initialization cleanup,
createSubagentsrollback) throw anAggregateError, primary failure first, cleanup failures after it.
Tests and operational boundaries
- The suite is offline. Pi's
fauxProvidersupplies model turns; use response factories to inspect a request's context and keep assertions outside them, because faux turns a thrown assertion into a model error. - Synchronize with
Promise.withResolversgates, never sleeps.setImmediateflushes appear only to show that nothing progressed. Lifecycle tests use a5_000ms timeout to detect a stuck gate or close. - Assert observable behavior — steps, statuses, request contexts, execution and request counts, signals, file contents and session state — never wording, spies or wiring.
- A pristine-versus-patched comparison needs a separately installed pristine
0.80.6(npm does not apply the patch; a Bun alias of the same package would be patched too). Run it from a disposable consumer, never against a second copy of the patched package. - Verify the native default path only against a disposable dedicated Btrfs seed. Never use an ordinary directory or the home subvolume, never use sudo or mount an image, and without a suitable seed report the default path as unverified.
- Tests and verification never use live LLM credentials.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

