introsio 0.0.0-stage → 0.3.0
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 +62 -0
- package/LICENSE +21 -0
- package/README.md +291 -3
- package/agents/claude.mjs +80 -0
- package/agents/codex.mjs +67 -0
- package/agents/common.mjs +200 -0
- package/agents/cursor.mjs +67 -0
- package/agents/gemini.mjs +63 -0
- package/agents/index.mjs +10 -0
- package/agents/opencode.mjs +65 -0
- package/agents/vscode.mjs +47 -0
- package/agents/windsurf.mjs +32 -0
- package/cli.mjs +536 -0
- package/hook/engine.mjs +286 -0
- package/hook/features/claims.mjs +265 -0
- package/hook/features/gates.mjs +134 -0
- package/hook/features/git.mjs +243 -0
- package/hook/features/log.mjs +70 -0
- package/hook/features/notes.mjs +88 -0
- package/hook/features/pause.mjs +340 -0
- package/hook/features/stopGuard.mjs +42 -0
- package/hook/features/workerId.mjs +55 -0
- package/hook/introsio-hook.mjs +95 -0
- package/hook/normalize.mjs +171 -0
- package/hook/respond.mjs +46 -0
- package/hook/state.mjs +136 -0
- package/lib/config.mjs +64 -0
- package/lib/git.mjs +120 -0
- package/lib/jsonFile.mjs +103 -0
- package/lib/lock.mjs +182 -0
- package/lib/managedBlock.mjs +19 -0
- package/lib/paths.mjs +59 -0
- package/lib/processTree.mjs +127 -0
- package/opencode/introsio.template.js +55 -0
- package/package.json +54 -6
- package/templates/execute.md +20 -0
- package/templates/pause.md +25 -0
- package/templates/resume.md +22 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to `introsio` (the `int` CLI) are recorded here.
|
|
4
|
+
The format follows [Keep a Changelog](https://keepachangelog.com/) and the
|
|
5
|
+
project uses [semantic versioning](https://semver.org/).
|
|
6
|
+
|
|
7
|
+
## [Unreleased]
|
|
8
|
+
|
|
9
|
+
## [0.3.0]
|
|
10
|
+
|
|
11
|
+
Run `int setup` again after updating: the installed hook engine is versioned, and
|
|
12
|
+
`int doctor` reports one that is behind.
|
|
13
|
+
|
|
14
|
+
### Added
|
|
15
|
+
- `--toolset execute` for `int setup`: the slim set of 13 tools for running a plan
|
|
16
|
+
that already exists (the claim → complete loop, pause / resume and the hand-off),
|
|
17
|
+
about a third of the tool definitions an agent otherwise carries on every turn.
|
|
18
|
+
`developer` stays the default; the choice is remembered.
|
|
19
|
+
- Lost claims: when a project reset revokes a task the session holds
|
|
20
|
+
(`CLAIM_REVOKED_BY_RESET`), the hook drops the claim and tells the agent why, so
|
|
21
|
+
the stop-guard no longer holds it to work that can no longer be finished.
|
|
22
|
+
- Daily MCP budgets: when a budget is used up (`PLAN_LIMIT_REACHED`), the agent is
|
|
23
|
+
told when it resets and to pause what it holds. A refused `claimTask` leaves no
|
|
24
|
+
claim, so the agent may stop.
|
|
25
|
+
- The command procedures name finished steps in `completeTask` / `pauseTask`
|
|
26
|
+
(`completedSubtasks`) instead of one call per step, size the outcome to the task,
|
|
27
|
+
and skip chat recaps between tasks.
|
|
28
|
+
|
|
29
|
+
### Changed
|
|
30
|
+
- The push guard refuses `git push --all` and `--branches` in github mode (they
|
|
31
|
+
push the default branch too); `--tags` still passes.
|
|
32
|
+
- `bash -c` / `sh -c` / `eval` scripts are checked like the bare command, behind
|
|
33
|
+
`env` / `sudo` prefixes and nested up to 3 levels, for both the push guard and the
|
|
34
|
+
secrets check.
|
|
35
|
+
|
|
36
|
+
### Fixed
|
|
37
|
+
- Claims lost when an agent ran the hooks of parallel tool calls at the same time:
|
|
38
|
+
per-session locks now take over abandoned locks safely, a waiter saves only its own
|
|
39
|
+
changes merged into what is on disk, and atomic writes retry the rename Windows
|
|
40
|
+
refuses while a file is open.
|
|
41
|
+
|
|
42
|
+
## [0.2.0]
|
|
43
|
+
|
|
44
|
+
Never published on its own; everything in it ships in 0.3.0.
|
|
45
|
+
|
|
46
|
+
### Added
|
|
47
|
+
- `/introsio-pause` and `/introsio-resume` for every agent (`int print-pause`,
|
|
48
|
+
`int print-resume` for Windsurf): stop a task anywhere and continue it exactly,
|
|
49
|
+
in the same or another agent.
|
|
50
|
+
- Hook feature `pause`: the working tree is snapshotted under
|
|
51
|
+
`refs/introsio/paused/<taskId>` when a task is paused (nothing on a branch
|
|
52
|
+
changes), the reported git position is checked, and the repository is compared
|
|
53
|
+
with a pause before it is resumed — EXACT / DRIFT / BLOCKED. Tasks left by a
|
|
54
|
+
session that died are named as interrupted, with its workerId.
|
|
55
|
+
- `int paused [--prune]`: pauses and interrupted work on this computer, offline.
|
|
56
|
+
- The push guard refuses pushing `refs/introsio/*` in every mode.
|
|
57
|
+
- MIT license (`LICENSE`), `author`, and this changelog.
|
|
58
|
+
|
|
59
|
+
## [0.1.0]
|
|
60
|
+
|
|
61
|
+
- Global setup for Claude Code, Codex, Gemini CLI, Cursor, OpenCode, VS Code
|
|
62
|
+
and Windsurf; `/introsio-execute`; stop-guard and related hooks; `int stats`.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Introsio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,291 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
# int — connect any coding agent to Introsio
|
|
2
|
+
|
|
3
|
+
One command connects your coding agents to Introsio, gives them
|
|
4
|
+
`/introsio-execute` for running a Developer Mode project, `/introsio-pause` and
|
|
5
|
+
`/introsio-resume` for stopping anywhere and continuing exactly, and installs
|
|
6
|
+
hooks that keep Introsio in step with what the agent actually did.
|
|
7
|
+
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
Needs Node 18 or newer and one or more coding agents.
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npx introsio setup # try it once, nothing stays installed
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install -g introsio # keeps the `int` command (`introsio` works too)
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
int setup # connect your agents, once per computer
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
From a clone, to run the code in a checkout instead of the published package (in
|
|
25
|
+
the Introsio monorepo this folder is `agent-kit/`):
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
node cli.mjs setup # from the monorepo root: node agent-kit/cli.mjs setup
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
`setup` finds the agents on this computer, or takes `--agents claude,codex,…`. It
|
|
32
|
+
installs **globally**, so it works in every repository you open, and copies the
|
|
33
|
+
hook engine to `~/.introsio/kit`, so the hooks never depend on this checkout.
|
|
34
|
+
|
|
35
|
+
| Agent | Connect (MCP) | Commands (`/introsio-execute`, `-pause`, `-resume`) | Hooks |
|
|
36
|
+
|---|---|---|---|
|
|
37
|
+
| Claude Code | `claude mcp add` (user scope) | `~/.claude/commands/` | blocking |
|
|
38
|
+
| Codex | `~/.codex/config.toml` | `/prompts:introsio-execute` (and `-pause`, `-resume`) | blocking |
|
|
39
|
+
| Gemini CLI | `~/.gemini/settings.json` | `~/.gemini/commands/` | blocking |
|
|
40
|
+
| Cursor | `~/.cursor/mcp.json` | `~/.cursor/commands/` | blocking (stop-hook reliability varies by Cursor version) |
|
|
41
|
+
| OpenCode | `opencode.json` | `commands/` | blocking (a plugin) |
|
|
42
|
+
| VS Code (Copilot) | user `mcp.json` | prompt file | none |
|
|
43
|
+
| Windsurf | `mcp_config.json` | `int print-execute` / `print-pause` / `print-resume` → paste as workflows | none |
|
|
44
|
+
|
|
45
|
+
**Signing in.** No key is stored anywhere. Each agent signs in through its own MCP
|
|
46
|
+
OAuth flow (Introsio supports dynamic client registration and PKCE). `setup` tells
|
|
47
|
+
you the exact step for each agent, for example `/mcp` in Claude Code or
|
|
48
|
+
`codex mcp login introsio`.
|
|
49
|
+
|
|
50
|
+
## How it works
|
|
51
|
+
|
|
52
|
+
The agent runs a project with the server's loop: `claimTask` → work → `completeTask`
|
|
53
|
+
with an outcome (ADR-0008). The hooks never call Introsio themselves; they have no
|
|
54
|
+
credential. They watch the agent's own Introsio calls and make sure it finishes
|
|
55
|
+
the loop.
|
|
56
|
+
|
|
57
|
+
- **After each Introsio call**, the hook records what the session holds: a
|
|
58
|
+
successful `claimTask` opens a task, a successful `completeTask` (or `updateTask`
|
|
59
|
+
to blocked/pending) closes it, and a refused call changes nothing. State lives
|
|
60
|
+
in `~/.introsio/sessions/<session>.json`, one file per session, so parallel
|
|
61
|
+
agents never collide.
|
|
62
|
+
- **When the agent tries to stop** with a task still open, it is sent back once,
|
|
63
|
+
with the exact call to make — and told to follow what the user asked first: if
|
|
64
|
+
the user only wanted the task claimed or asked to pause, it releases it instead
|
|
65
|
+
of doing the work. Stopping again with the same tasks open is taken as a
|
|
66
|
+
decision: it is let go with a visible warning and not asked again. Agents whose
|
|
67
|
+
hooks don't see MCP calls have the open set rebuilt from the transcript, read
|
|
68
|
+
incrementally.
|
|
69
|
+
- **When the server takes a task away**, the hook lets go of it and says why, so
|
|
70
|
+
the stop is never held for work nobody can finish: the task was deleted, another
|
|
71
|
+
worker holds it now, or the person reset the project's execution
|
|
72
|
+
(`CLAIM_REVOKED_BY_RESET`: that work no longer counts, so the agent leaves it and
|
|
73
|
+
claims the next).
|
|
74
|
+
- **When a daily MCP budget is used up** (`PLAN_LIMIT_REACHED`), the agent is told
|
|
75
|
+
when it resets and to pause what it holds. A refused `claimTask` leaves no claim,
|
|
76
|
+
so it may stop; pausing and completing are reporting calls the budget never
|
|
77
|
+
refuses.
|
|
78
|
+
- A hook costs **no tokens** unless it prints. The engine decides in under a
|
|
79
|
+
millisecond; one hook process, including Node start-up, takes about 50 ms.
|
|
80
|
+
`INTROSIO_HOOKS=off` turns every hook off for a session.
|
|
81
|
+
|
|
82
|
+
The hooks also include the following checks. Each one can be switched off
|
|
83
|
+
(`int disable <name>`).
|
|
84
|
+
|
|
85
|
+
| Feature | What it does |
|
|
86
|
+
|---|---|
|
|
87
|
+
| `stop-guard` | No finishing while a claimed task is open |
|
|
88
|
+
| `test-gate` | `completeTask` waits for the repo's check command (`int gate set "npm test"`). Passes are cached per work tree, and a failure sends the last 40 lines back |
|
|
89
|
+
| `shipped-gate` | **local** mode: work must be committed. **github** mode: committed, pushed, off the default branch, `outcome.branch` recorded |
|
|
90
|
+
| `push-guard` | No push to the default branch, no force push, no mirror, no `--all`; in local mode, no push at all. Also checked inside `bash -c` / `sh -c` / `eval` wrappers (a guard-rail, not a sandbox: script files and other interpreters are not inspected) |
|
|
91
|
+
| `secrets` | Commits and pushes adding keys, private keys or `.env` files are refused, naming the file:line, never the value |
|
|
92
|
+
| `scope` | One soft note per file edited outside the files the task names |
|
|
93
|
+
| `worker-id` | Refuses a claim with another live session's workerId, and a second claim without one |
|
|
94
|
+
| `compact-recovery` | After context compaction: the task, workerId, subtask progress and context revision |
|
|
95
|
+
| `lease` | One reminder when a claim is 60% through its lease with no progress reported |
|
|
96
|
+
| `reread` | Refuses once a context read the agent already has, or a schedule read straight after `nowReady` |
|
|
97
|
+
| `log` | `~/.introsio/log.jsonl`, summed up by `int stats` |
|
|
98
|
+
| `pause` | Snapshots the working tree when a task is paused, and checks the repository against a pause before it is resumed (below) |
|
|
99
|
+
|
|
100
|
+
The gates and git guards only act in sessions that have used Introsio, and only
|
|
101
|
+
on tasks that session claimed. Completing a personal task, or pushing in a repo
|
|
102
|
+
that has nothing to do with Introsio, is never touched.
|
|
103
|
+
|
|
104
|
+
### Modes: keep the code on this computer, or ship it to GitHub
|
|
105
|
+
|
|
106
|
+
| Mode | Before a task can be Done | `git push` |
|
|
107
|
+
|---|---|---|
|
|
108
|
+
| `github` (auto when the Introsio project is linked to a GitHub repository) | committed, pushed on its own branch, `outcome.branch` recorded | allowed, except to the default branch or forced |
|
|
109
|
+
| `local` (auto otherwise) | committed | blocked |
|
|
110
|
+
| `off` | no check | no check |
|
|
111
|
+
|
|
112
|
+
Set a mode per repository with `int mode local`, `int mode github`,
|
|
113
|
+
`int mode off` or `int mode auto`.
|
|
114
|
+
|
|
115
|
+
## Pause and resume
|
|
116
|
+
|
|
117
|
+
Agents run out of usage, context or time in the middle of a task. Two commands
|
|
118
|
+
make that safe (ADR-0011 in the Introsio repository):
|
|
119
|
+
|
|
120
|
+
```
|
|
121
|
+
/introsio-pause [--release] [note] # in the agent, before it stops
|
|
122
|
+
/introsio-resume [task id | project] # in any agent, any time later
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
```bash
|
|
126
|
+
int paused # in a terminal: what is paused or interrupted on this computer
|
|
127
|
+
```
|
|
128
|
+
|
|
129
|
+
**Pause** settles the subtasks, then calls `pauseTask` with a note written for
|
|
130
|
+
someone with none of the conversation, the next steps, the subtask it was on and
|
|
131
|
+
the git position. Introsio keeps the task in progress, ends the lease, and never
|
|
132
|
+
hands it to another worker automatically. At that moment the hook saves the whole
|
|
133
|
+
working tree (tracked changes and untracked files) as a commit under
|
|
134
|
+
`refs/introsio/paused/<taskId>`: your branch, files, index and stash are not
|
|
135
|
+
touched, and the ref is never pushed. It also checks the branch and commit the
|
|
136
|
+
agent reports against the real ones. `--release` commits (and in github mode
|
|
137
|
+
pushes) the work first and hands the task to any worker.
|
|
138
|
+
|
|
139
|
+
**Resume** reads the pause without claiming the task, and the hook compares the
|
|
140
|
+
repository with it, in code, and answers:
|
|
141
|
+
|
|
142
|
+
| Verdict | Means | The agent then |
|
|
143
|
+
|---|---|---|
|
|
144
|
+
| **EXACT** | same repository, branch, HEAD and working tree as the pause | takes the task back (`claimTask { taskId, resume: true }`) and continues from the note |
|
|
145
|
+
| **DRIFT** | something moved: other branch, new commits (listed with authors), HEAD behind, rewritten history, files changed since the pause, the unfinished work wiped (with the exact `git restore` command from the snapshot), the task edited | shows you the differences and asks: restore, continue as it is, or leave it paused |
|
|
146
|
+
| **BLOCKED** | wrong repository, a merge/rebase half done, the unfinished code only on another computer, another live session on the task | does not resume, and says why |
|
|
147
|
+
|
|
148
|
+
If an agent died without pausing, resume names the task as **interrupted**, with
|
|
149
|
+
the dead session's workerId, so it is taken over at once instead of waiting for
|
|
150
|
+
the lease to expire. Completing the task removes its snapshot;
|
|
151
|
+
`int paused --prune [--days 30]` removes old ones.
|
|
152
|
+
|
|
153
|
+
| # | Case | What happens |
|
|
154
|
+
|---|---|---|
|
|
155
|
+
| P1 | Usage cut off before any pause | The task shows as interrupted (local session dead); resume takes it over with that workerId |
|
|
156
|
+
| P2 | Cut off between the snapshot and `pauseTask` | No ref is kept (written only after the pause lands); resume treats it as P1 |
|
|
157
|
+
| P3 | Two resumes of one pause | Compare-and-swap on the pause: the second is refused, naming who resumed it |
|
|
158
|
+
| P4 | A worker that does not hold the task pauses it | Refused (409) |
|
|
159
|
+
| P5 | The lease ran out before the pause | Allowed while nobody else took the task |
|
|
160
|
+
| P6 | Someone took the task after the lease ran out | Refused, and the hook drops the claim (R16) |
|
|
161
|
+
| P7 | Other workers looking for work | A paused task is never handed out; `reason: "paused"` when only paused work is left; resuming a task another live session is working is BLOCKED |
|
|
162
|
+
| P8 | `--release` | Refused while the task's files are uncommitted; once committed, any worker gets the task and the note |
|
|
163
|
+
| P9 | Completed, blocked or personal tasks | Cannot be paused |
|
|
164
|
+
| P10 | Branch switched, commits added, reset back, rebased or force-pushed | DRIFT with each difference named |
|
|
165
|
+
| P11 | Working tree reset or cleaned | DRIFT with the exact `git restore --source=<snapshot>` command, run only after you agree |
|
|
166
|
+
| P12 | Untracked and ignored files | Untracked files are in the snapshot; ignored files never are |
|
|
167
|
+
| P13 | Not a git repository, detached HEAD, merge or rebase half done | Paused without a snapshot / recorded as no branch / resume BLOCKED until it is finished |
|
|
168
|
+
| P14 | A snapshot that takes too long (huge tree) | The pause goes through without one, and says so; resume compares file lists |
|
|
169
|
+
| P15 | Secrets | Only paths and commit ids go to Introsio; `refs/introsio/*` can never be pushed |
|
|
170
|
+
| P16 | The task was edited while paused | Resume says to re-read it before coding |
|
|
171
|
+
| P17 | Several tasks held, one paused | The others still hold the stop |
|
|
172
|
+
| P18 | Windows / macOS path spellings | One repository key (R24) |
|
|
173
|
+
| P19 | Agents without hooks (VS Code, Windsurf) | The commands list the same checks to run by hand |
|
|
174
|
+
| P20 | Completed, undone, released or moved out of in-progress in the app | The pause ends; completing removes the snapshot and local record |
|
|
175
|
+
|
|
176
|
+
Tests: `test/pause.test.js` (real git repositories, the real hook script), and the
|
|
177
|
+
server's `backend-node/src/tests/agentPause.test.js`.
|
|
178
|
+
|
|
179
|
+
## Edge cases (researched, reproduced, fixed)
|
|
180
|
+
|
|
181
|
+
Each of these was first reproduced against the earlier kit, then fixed, and is kept
|
|
182
|
+
as a regression test in `test/edgecases.test.js` (same numbers).
|
|
183
|
+
|
|
184
|
+
| # | What broke | What the kit does now |
|
|
185
|
+
|---|---|---|
|
|
186
|
+
| R1 | Agents run the hooks of parallel tool calls at the same time; concurrent writes lost claims (10 of 12 kept) | Every session update runs under a per-session lock (`lib/lock.mjs`): the holder's pid is in the lock; an abandoned lock (owner gone, after a 2 s grace — on Windows a released lock lingers while another process has it open) is taken over through a guard that re-checks it, a live holder's only after 60 s; release retries Windows' transient errors. A waiter goes on unlocked after 6 s and then saves only its own changes, merged into what is on disk (`mergeSessionChanges`, under the lock again). Atomic writes retry a rename Windows refuses while the file is open (`lib/jsonFile.mjs`) |
|
|
187
|
+
| R2 | A timed-out test gate left its child processes (test workers) running | The gate runs in its own process group; on timeout, on exit, or if the agent kills the hook, the whole group is killed (`lib/processTree.mjs`) |
|
|
188
|
+
| R3 | A diff over 16 MB made the gate cache blind to changes, so stale passes were reused | The cache key is the `git stash create` tree id plus every untracked file's size/mtime; an unreadable tree is never cached |
|
|
189
|
+
| R4 | A bare `git push` from a branch whose upstream is main went through | A bare push is checked against `@{push}` (honours `push.default`) |
|
|
190
|
+
| R5 | The person's own uncommitted files blocked the agent's completion forever | Only the task's files are checked (edited this session ∪ `outcome.files`); with none known, the refusal says to list them |
|
|
191
|
+
| R6 | A Claude subagent's stop was blocked by its parent's claim | `SubagentStop` is not hooked |
|
|
192
|
+
| R7 | A claim on a deleted task re-blocked every later stop | A 404 drops the claim; a set that was let go never re-blocks |
|
|
193
|
+
| R8 | Payloads without a session id all shared one "unknown" session | The agent process id becomes the session key |
|
|
194
|
+
| R9 | A crashed session's workerId was refused after a restart | A clash counts only if the other agent process is alive (or, without a pid, heard from in the last 10 min) |
|
|
195
|
+
| R10 | A failing gate printing one huge line flooded the context | Output tail: 40 lines × 300 chars, 3000 in all; every message at most 6000 chars |
|
|
196
|
+
| R11 | AWS's documented example key (in tests everywhere) blocked commits | Lines with `EXAMPLE`, `int:allow-secret`, `pragma: allowlist secret`, `gitleaks:allow` or `nosec` are skipped |
|
|
197
|
+
| R12 | GUI apps (Cursor, VS Code) start without the shell's PATH, so `node` (nvm, fnm, Homebrew) wasn't found | Global hooks name the absolute Node that ran `int setup`; `int doctor` warns when it disappears |
|
|
198
|
+
| R13 | Windows paths were written with doubled backslashes | Paths in commands use forward slashes |
|
|
199
|
+
| R14 | A gate timeout above the agents' 900 s hook timeout was accepted, so the agent cut the hook off and the completion went through unchecked | At most 840 s, enforced by the CLI and the engine |
|
|
200
|
+
| R15 | Codex Stop got empty stdout where Codex expects JSON | Codex always gets JSON (`{}` when there's nothing to say) |
|
|
201
|
+
| R16 | A task another worker took over still held this session | A 409 naming another worker drops the claim and tells the agent |
|
|
202
|
+
| R17 | The guard made the agent do work the user had said not to do (found in a real Claude Code run) | The message puts the user's instruction first and offers release (`statusState: "pending"`); one reminder only |
|
|
203
|
+
| R18 | An agent that keeps stdin open hung the hook | The payload is read until it parses (2 s idle, 10 s cap) |
|
|
204
|
+
| R19 | A long Codex transcript was re-parsed on every stop (85 MB: ~300 ms each) | Read incrementally from a saved offset (~50 ms after the first) |
|
|
205
|
+
| R20 | The re-read guard refused context to a subagent that never had it | The refusal says to call again; the second identical call goes through |
|
|
206
|
+
| R21 | A parallel worker without a workerId was told to reuse its parent's | It is told to pick its own (`<id>-2`) |
|
|
207
|
+
| R22 | A hand-broken settings file was silently replaced by the next command | Commands refuse to write a settings file they cannot read; hooks keep running on defaults |
|
|
208
|
+
| R23 | Internal hook errors vanished | They go to `~/.introsio/errors.log` (1 MB, rotated); `int doctor` shows recent ones; the agent still gets valid output |
|
|
209
|
+
| R24 | On Windows, git (`C:/…`), Node (`C:\…`) and temp folders (`MAHESH~1`) spell one folder three ways, so `int mode` / `int gate` settings were never found by the hooks and edited files looked "outside" the repo (found on the first Windows run) | One canonical spelling (`canonicalPath` / `repoKey` in `lib/paths.mjs`, case-insensitive on Windows) for every settings key and file comparison; CI now runs on Windows, macOS and Linux |
|
|
210
|
+
| R25 | `git push --all origin` went through: the guard skipped `--all`, which pushes every local branch, the default one included | `--all` / `--branches` are refused in github mode; `--tags` still passes |
|
|
211
|
+
| R26 | `bash -c "git push origin main"` (or a wrapped commit of a key) went through: the quoted script was one word with no `git` in it | `sh`/`bash`/`zsh`/`dash`/`ksh -c` and `eval` scripts are checked like the bare command (behind `env`/`sudo` prefixes, nested up to 3 levels) for both the push guard and the secrets check |
|
|
212
|
+
|
|
213
|
+
Tested end to end with Claude Code 2.1.312 (headless `claude -p`, a stub Introsio
|
|
214
|
+
MCP server over stdio, the installed hooks):
|
|
215
|
+
- a claim is recorded from Claude's real payload, and the stop is refused until `completeTask`;
|
|
216
|
+
- "only claim it" leaves the work undone, and the agent stops after one reminder;
|
|
217
|
+
- a failing gate refuses the first `completeTask` in PreToolUse; the agent reads the
|
|
218
|
+
failure, fixes it, commits locally (local mode: no push) and completes.
|
|
219
|
+
|
|
220
|
+
## Commands
|
|
221
|
+
|
|
222
|
+
```
|
|
223
|
+
int setup [--agents a,b] [--project <repo>] [--toolset developer|execute|all] [--url <mcp url>] [--dry-run]
|
|
224
|
+
int uninstall [--agents a,b] [--project <repo>]
|
|
225
|
+
int status | doctor
|
|
226
|
+
int mode github|local|off|auto
|
|
227
|
+
int gate set "<cmd>" [--timeout <sec>] | gate off | gate run | gate
|
|
228
|
+
int features | enable <name> | disable <name>
|
|
229
|
+
int claims | claims clear
|
|
230
|
+
int paused [--prune [--days 30]]
|
|
231
|
+
int stats [--since 7d] [--project <id>] [--json]
|
|
232
|
+
int print-execute | print-pause | print-resume
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
- `--project <repo>` installs into one repository instead (committed, so a team
|
|
236
|
+
shares it). The kit is copied to `<repo>/.introsio/kit` and the configs use
|
|
237
|
+
repo-relative paths.
|
|
238
|
+
- `--toolset` chooses which Introsio tools the agents load, and is remembered.
|
|
239
|
+
`developer` (the default) plans and executes. `execute` is the slim set for
|
|
240
|
+
running a plan that already exists — the 13 tools of the claim → complete loop,
|
|
241
|
+
pause / resume and the hand-off, about a third of the tool definitions an agent
|
|
242
|
+
carries on every turn. It cannot create or edit a plan; switch back with
|
|
243
|
+
`int setup --toolset developer`.
|
|
244
|
+
- `--url` points the agents at another MCP server, such as a local backend; it is
|
|
245
|
+
remembered.
|
|
246
|
+
- A config file with comments is never rewritten. `setup` prints what to add to it.
|
|
247
|
+
- `uninstall` removes only what `setup` added.
|
|
248
|
+
|
|
249
|
+
## Layout
|
|
250
|
+
|
|
251
|
+
- `cli.mjs` — the `int` command
|
|
252
|
+
- `agents/<agent>.mjs` — one adapter per agent: detect, connect, command, hooks, uninstall, status
|
|
253
|
+
- `hook/introsio-hook.mjs` → `normalize.mjs` (each agent's payload into one shape) → `engine.mjs` (the decisions) → `respond.mjs` (each agent's output format)
|
|
254
|
+
- `hook/features/*.mjs` — one pure module per feature
|
|
255
|
+
- `opencode/introsio.template.js` — the OpenCode plugin (it imports the same engine)
|
|
256
|
+
- `templates/execute.md`, `pause.md`, `resume.md` — the three command procedures, rendered into each agent's command format
|
|
257
|
+
|
|
258
|
+
Tests: `npm test` in this folder. They use plain
|
|
259
|
+
`node:assert/strict`, a scratch HOME and real git repositories.
|
|
260
|
+
|
|
261
|
+
Hook formats follow each agent's documentation as of October 2026. Agents change
|
|
262
|
+
these often: run `int doctor` after updating an agent.
|
|
263
|
+
|
|
264
|
+
## Publishing a release (maintainers)
|
|
265
|
+
|
|
266
|
+
The package is `introsio` on npm (commands `int` and `introsio`).
|
|
267
|
+
|
|
268
|
+
1. Bump `version` in `package.json` and describe the release in `CHANGELOG.md` (`int doctor` tells users on older hooks to re-run `int setup`), and merge.
|
|
269
|
+
2. Add the repository secret `NPM_TOKEN` once (an npm Automation token that may publish `introsio`).
|
|
270
|
+
3. Tag the release; `.github/workflows/agent-kit-release.yml` runs the tests, checks the tag against the version, and publishes with provenance:
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
git tag agent-kit-v0.3.0 && git push origin agent-kit-v0.3.0
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
To publish by hand instead: `npm login`, then `npm publish` from this folder (the tests run first via `prepublishOnly`).
|
|
277
|
+
|
|
278
|
+
The code is edited only in the Introsio monorepo's `agent-kit/` folder. The
|
|
279
|
+
standalone [Introsio-cli](https://github.com/introsio/Introsio-cli) repository is
|
|
280
|
+
a mirror of that folder, updated from the monorepo root (never edited directly):
|
|
281
|
+
|
|
282
|
+
```bash
|
|
283
|
+
git fetch cli
|
|
284
|
+
git subtree split --prefix=agent-kit -b cli-only
|
|
285
|
+
git push cli cli-only:main
|
|
286
|
+
```
|
|
287
|
+
|
|
288
|
+
## License
|
|
289
|
+
|
|
290
|
+
[MIT](./LICENSE) © 2026 Introsio. This license covers the `int` CLI in
|
|
291
|
+
`agent-kit/` only; the Introsio service it connects to is a separate product.
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Claude Code: MCP via `claude mcp add` (or ~/.claude.json / .mcp.json), /introsio-execute as a command, hooks in settings.json.
|
|
2
|
+
import { join, editJson, setMatcherHooks, removeMatcherHooks, hasOurHooks, hookCommand, markdownCommand, writeCommands, removeCommands, commandsStatus, existsDir, hasCli, SERVER_NAME, COMMAND_NAME } from './common.mjs';
|
|
3
|
+
import { readJsonSafe } from '../lib/jsonFile.mjs';
|
|
4
|
+
|
|
5
|
+
const paths = (ctx) => {
|
|
6
|
+
const base = ctx.scope === 'project' ? ctx.root : ctx.home;
|
|
7
|
+
const commandFile = (name) => join(base, '.claude', 'commands', `${name}.md`);
|
|
8
|
+
return {
|
|
9
|
+
settings: join(base, '.claude', 'settings.json'),
|
|
10
|
+
mcp: ctx.scope === 'project' ? join(ctx.root, '.mcp.json') : join(ctx.home, '.claude.json'),
|
|
11
|
+
command: commandFile(COMMAND_NAME),
|
|
12
|
+
commandFile,
|
|
13
|
+
};
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
function hookGroups(ctx) {
|
|
17
|
+
const cmd = (event, timeout) => ({ type: 'command', command: hookCommand(ctx, 'claude', event), timeout });
|
|
18
|
+
return {
|
|
19
|
+
SessionStart: [{ matcher: 'compact', hooks: [cmd('SessionStart', 10)] }],
|
|
20
|
+
PreToolUse: [
|
|
21
|
+
// Completion runs the test gate, so it may take minutes.
|
|
22
|
+
{ matcher: 'mcp__.*', hooks: [cmd('PreToolUse', 900)] },
|
|
23
|
+
{ matcher: 'Bash', hooks: [cmd('PreToolUse', 60)] },
|
|
24
|
+
],
|
|
25
|
+
PostToolUse: [{ matcher: '.*', hooks: [cmd('PostToolUse', 15)] }],
|
|
26
|
+
PreCompact: [{ hooks: [cmd('PreCompact', 10)] }],
|
|
27
|
+
Stop: [{ hooks: [cmd('Stop', 15)] }],
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export default {
|
|
32
|
+
id: 'claude',
|
|
33
|
+
label: 'Claude Code',
|
|
34
|
+
hooks: 'blocking',
|
|
35
|
+
detect: (ctx) => existsDir(join(ctx.home, '.claude')) || hasCli('claude', ctx.env),
|
|
36
|
+
install(ctx, writer) {
|
|
37
|
+
const p = paths(ctx);
|
|
38
|
+
const report = { connect: null, command: p.command, hooks: 'blocking', next: [] };
|
|
39
|
+
if (ctx.scope === 'user' && hasCli('claude', ctx.env)) {
|
|
40
|
+
const listed = writer.run('claude', ['mcp', 'get', SERVER_NAME]);
|
|
41
|
+
if (listed.ok && !writer.dryRun && listed.out.includes(ctx.url)) report.connect = 'already connected';
|
|
42
|
+
else {
|
|
43
|
+
if (listed.ok && !writer.dryRun) writer.run('claude', ['mcp', 'remove', '--scope', 'user', SERVER_NAME]);
|
|
44
|
+
const added = writer.run('claude', ['mcp', 'add', '--scope', 'user', '--transport', 'http', SERVER_NAME, ctx.url]);
|
|
45
|
+
report.connect = added.ok ? 'added' : `could not add (${added.out.slice(0, 120)}) — run: claude mcp add --scope user --transport http ${SERVER_NAME} ${ctx.url}`;
|
|
46
|
+
}
|
|
47
|
+
} else {
|
|
48
|
+
const result = editJson(writer, p.mcp, (config) => {
|
|
49
|
+
config.mcpServers = config.mcpServers ?? {};
|
|
50
|
+
const next = { type: 'http', url: ctx.url };
|
|
51
|
+
if (JSON.stringify(config.mcpServers[SERVER_NAME]) === JSON.stringify(next)) return false;
|
|
52
|
+
config.mcpServers[SERVER_NAME] = next;
|
|
53
|
+
return true;
|
|
54
|
+
});
|
|
55
|
+
report.connect = result.error ?? (result.manual ? `manual — add "${SERVER_NAME}": { "type": "http", "url": "${ctx.url}" } to mcpServers in ${p.mcp}` : result.changed ? 'added' : 'already connected');
|
|
56
|
+
}
|
|
57
|
+
report.next.push('In Claude Code run /mcp, pick "introsio" and sign in. Then: /introsio-execute <project> — /introsio-pause before you stop, /introsio-resume to continue');
|
|
58
|
+
writeCommands(writer, p.commandFile, (command) => markdownCommand(ctx, { command, argumentHint: true }));
|
|
59
|
+
const hooks = editJson(writer, p.settings, (settings) => setMatcherHooks(settings, hookGroups(ctx)));
|
|
60
|
+
if (hooks.manual || hooks.error) report.hooks = hooks.error ?? `manual — ${p.settings} has comments; add the hooks shown by \`int setup --print claude\``;
|
|
61
|
+
return report;
|
|
62
|
+
},
|
|
63
|
+
uninstall(ctx, writer) {
|
|
64
|
+
const p = paths(ctx);
|
|
65
|
+
if (ctx.scope === 'user' && hasCli('claude', ctx.env)) writer.run('claude', ['mcp', 'remove', '--scope', 'user', SERVER_NAME]);
|
|
66
|
+
else editJson(writer, p.mcp, (config) => (config.mcpServers?.[SERVER_NAME] ? (delete config.mcpServers[SERVER_NAME], true) : false));
|
|
67
|
+
editJson(writer, p.settings, (settings) => removeMatcherHooks(settings));
|
|
68
|
+
removeCommands(writer, p.commandFile);
|
|
69
|
+
},
|
|
70
|
+
status(ctx) {
|
|
71
|
+
const p = paths(ctx);
|
|
72
|
+
const mcp = readJsonSafe(p.mcp, {});
|
|
73
|
+
return {
|
|
74
|
+
connect: mcp.mcpServers?.[SERVER_NAME] ? 'yes' : (ctx.scope === 'user' ? 'see `claude mcp list`' : 'no'),
|
|
75
|
+
command: commandsStatus(p.commandFile),
|
|
76
|
+
hooks: hasOurHooks(readJsonSafe(p.settings, {})) ? 'blocking' : 'not installed',
|
|
77
|
+
};
|
|
78
|
+
},
|
|
79
|
+
print: (ctx) => ({ hooks: hookGroups(ctx) }),
|
|
80
|
+
};
|
package/agents/codex.mjs
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// Codex: MCP server in config.toml (a managed block), /prompts:introsio-execute, hooks in hooks.json.
|
|
2
|
+
import { join, editJson, setMatcherHooks, removeMatcherHooks, hasOurHooks, hookCommand, markdownCommand, writeCommands, removeCommands, commandsStatus, existsDir, hasCli, SERVER_NAME, COMMAND_NAME } from './common.mjs';
|
|
3
|
+
import { readJsonSafe, readText } from '../lib/jsonFile.mjs';
|
|
4
|
+
import { withBlock, withoutBlock, hasBlock } from '../lib/managedBlock.mjs';
|
|
5
|
+
|
|
6
|
+
const base = (ctx) => (ctx.scope === 'project' ? join(ctx.root, '.codex') : join(ctx.home, '.codex'));
|
|
7
|
+
const paths = (ctx) => ({
|
|
8
|
+
config: join(base(ctx), 'config.toml'),
|
|
9
|
+
hooks: join(base(ctx), 'hooks.json'),
|
|
10
|
+
command: join(base(ctx), 'prompts', `${COMMAND_NAME}.md`),
|
|
11
|
+
commandFile: (name) => join(base(ctx), 'prompts', `${name}.md`),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
function hookGroups(ctx) {
|
|
15
|
+
const cmd = (event, timeout) => ({ type: 'command', command: hookCommand(ctx, 'codex', event), timeout });
|
|
16
|
+
return {
|
|
17
|
+
SessionStart: [{ hooks: [cmd('SessionStart', 10)] }],
|
|
18
|
+
PreToolUse: [{ matcher: 'mcp__.*|Bash|shell|exec_command', hooks: [cmd('PreToolUse', 900)] }],
|
|
19
|
+
PostToolUse: [{ matcher: '.*', hooks: [cmd('PostToolUse', 15)] }],
|
|
20
|
+
PreCompact: [{ hooks: [cmd('PreCompact', 10)] }],
|
|
21
|
+
PostCompact: [{ hooks: [cmd('PostCompact', 10)] }],
|
|
22
|
+
Stop: [{ hooks: [cmd('Stop', 15)] }],
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/** True when the user already configured [mcp_servers.introsio] themselves (outside our block). */
|
|
27
|
+
const userDefinedServer = (text) => /^\s*\[mcp_servers\.introsio\]/m.test(withoutBlock(text ?? ''));
|
|
28
|
+
|
|
29
|
+
export default {
|
|
30
|
+
id: 'codex',
|
|
31
|
+
label: 'Codex',
|
|
32
|
+
hooks: 'blocking',
|
|
33
|
+
detect: (ctx) => existsDir(join(ctx.home, '.codex')) || hasCli('codex', ctx.env),
|
|
34
|
+
install(ctx, writer) {
|
|
35
|
+
const p = paths(ctx);
|
|
36
|
+
const report = { connect: null, command: p.command, hooks: 'blocking', next: [] };
|
|
37
|
+
const text = readText(p.config) ?? '';
|
|
38
|
+
if (userDefinedServer(text)) report.connect = 'already configured in config.toml';
|
|
39
|
+
else {
|
|
40
|
+
const body = `[mcp_servers.${SERVER_NAME}]\nurl = ${JSON.stringify(ctx.url)}`;
|
|
41
|
+
report.connect = writer.writeText(p.config, withBlock(text, body)) ? 'added' : 'already connected';
|
|
42
|
+
}
|
|
43
|
+
report.next.push(`Sign in: codex mcp login ${SERVER_NAME}. Then in Codex: /prompts:${COMMAND_NAME} <project> (also /prompts:introsio-pause and /prompts:introsio-resume)`);
|
|
44
|
+
report.next.push('If your Codex version keeps hooks behind a flag, add to config.toml: [features] codex_hooks = true');
|
|
45
|
+
writeCommands(writer, p.commandFile, (command) => markdownCommand(ctx, { command, argumentHint: true }));
|
|
46
|
+
const hooks = editJson(writer, p.hooks, (config) => setMatcherHooks(config, hookGroups(ctx)));
|
|
47
|
+
if (hooks.manual || hooks.error) report.hooks = hooks.error ?? `manual — ${p.hooks} has comments`;
|
|
48
|
+
return report;
|
|
49
|
+
},
|
|
50
|
+
uninstall(ctx, writer) {
|
|
51
|
+
const p = paths(ctx);
|
|
52
|
+
const text = readText(p.config);
|
|
53
|
+
if (text && hasBlock(text)) writer.writeText(p.config, withoutBlock(text));
|
|
54
|
+
editJson(writer, p.hooks, (config) => removeMatcherHooks(config));
|
|
55
|
+
removeCommands(writer, p.commandFile);
|
|
56
|
+
},
|
|
57
|
+
status(ctx) {
|
|
58
|
+
const p = paths(ctx);
|
|
59
|
+
const text = readText(p.config) ?? '';
|
|
60
|
+
return {
|
|
61
|
+
connect: hasBlock(text) || userDefinedServer(text) ? 'yes' : 'no',
|
|
62
|
+
command: commandsStatus(p.commandFile),
|
|
63
|
+
hooks: hasOurHooks(readJsonSafe(p.hooks, {})) ? 'blocking' : 'not installed',
|
|
64
|
+
};
|
|
65
|
+
},
|
|
66
|
+
print: (ctx) => ({ hooks: hookGroups(ctx) }),
|
|
67
|
+
};
|