kijito-tools 0.2.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.
Files changed (104) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +6 -0
  3. package/README.md +220 -0
  4. package/bin/cli.js +34 -0
  5. package/install.sh +161 -0
  6. package/package.json +50 -0
  7. package/providers/_shared/wake-core.mjs +358 -0
  8. package/providers/claude/CLAUDE.md.snippet +31 -0
  9. package/providers/claude/install.sh +186 -0
  10. package/providers/claude/scripts/arm-session.sh +66 -0
  11. package/providers/claude/scripts/claude-armed.sh +101 -0
  12. package/providers/claude/scripts/heartbeat-watchdog.sh +209 -0
  13. package/providers/claude/scripts/inbox-selftest.sh +277 -0
  14. package/providers/claude/scripts/kijito-persona-lib.sh +94 -0
  15. package/providers/claude/scripts/kijito-qa-pass.sh +12 -0
  16. package/providers/claude/scripts/lifecycle-lib.sh +167 -0
  17. package/providers/claude/scripts/myctx.sh +46 -0
  18. package/providers/claude/scripts/self-clear.sh +134 -0
  19. package/providers/claude/scripts/session-autosend.sh +85 -0
  20. package/providers/claude/scripts/session-catchup-hint.sh +330 -0
  21. package/providers/claude/scripts/statusline-context.sh +67 -0
  22. package/providers/claude/skills/kijito-qa-memory/SKILL.md +110 -0
  23. package/providers/claude/skills/kijito-recall/SKILL.md +53 -0
  24. package/providers/claude/skills/kijito-start/SKILL.md +122 -0
  25. package/providers/claude/wiring/README.md +93 -0
  26. package/providers/claude/wiring/kijito-heartbeat@.service +21 -0
  27. package/providers/codex/README.md +75 -0
  28. package/providers/codex/codex-kijito-parity-plan.md +265 -0
  29. package/providers/codex/docs-codex-setup.md +64 -0
  30. package/providers/codex/install.mjs +184 -0
  31. package/providers/codex/n0-capability-probe-protocol.md +472 -0
  32. package/providers/codex/n0-harness/README.md +57 -0
  33. package/providers/codex/n0-harness/cli.mjs +58 -0
  34. package/providers/codex/n0-harness/evidence-manifest.mjs +77 -0
  35. package/providers/codex/n0-harness/fixture.mjs +279 -0
  36. package/providers/codex/n0-harness/lib.mjs +141 -0
  37. package/providers/codex/n0-harness/manifest.mjs +36 -0
  38. package/providers/codex/n0-harness/oracle.mjs +464 -0
  39. package/providers/codex/n0-harness/parser.mjs +200 -0
  40. package/providers/codex/n0-harness/prompt.mjs +43 -0
  41. package/providers/codex/n0-harness/snapshot.mjs +120 -0
  42. package/providers/codex/n0-harness/specimen.mjs +37 -0
  43. package/providers/codex/notify/kijito-notify-count.mjs +117 -0
  44. package/providers/codex/notify/kijito-notify-count.test.mjs +76 -0
  45. package/providers/codex/plans/gate4-battery-log.md +184 -0
  46. package/providers/codex/plans/gate4-battery-protocol.md +43 -0
  47. package/providers/codex/plans/hive-user-first-plan-QA.md +34 -0
  48. package/providers/codex/plans/hive-user-first-plan.md +247 -0
  49. package/providers/codex/release-manifest.json +53 -0
  50. package/providers/codex/same-chat-continuation-plan-gate.md +235 -0
  51. package/providers/codex/same-chat-continuation-plan.md +458 -0
  52. package/providers/codex/skills/kijito-qa-memory/SKILL.md +193 -0
  53. package/providers/codex/skills/kijito-qa-memory/agents/openai.yaml +4 -0
  54. package/providers/codex/skills/kijito-recall/SKILL.md +53 -0
  55. package/providers/codex/skills/kijito-start/SKILL.md +173 -0
  56. package/providers/codex/skills/kijito-start/agents/openai.yaml +4 -0
  57. package/providers/codex/test/n0-cli-refusal.test.mjs +31 -0
  58. package/providers/codex/test/n0-counterexample-matrix.test.mjs +118 -0
  59. package/providers/codex/test/n0-guard-census-core.mjs +1372 -0
  60. package/providers/codex/test/n0-guard-census.json +35479 -0
  61. package/providers/codex/test/n0-guard-census.mjs +31 -0
  62. package/providers/codex/test/n0-guard-census.test.mjs +374 -0
  63. package/providers/codex/test/n0-guard-counterexamples.mjs +1068 -0
  64. package/providers/codex/test/n0-guard-independent-projection.mjs +70 -0
  65. package/providers/codex/test/n0-guard-independent-projection.test.mjs +53 -0
  66. package/providers/codex/test/n0-guard-manifest-author.mjs +424 -0
  67. package/providers/codex/test/n0-guard-mutation-operators.test.mjs +244 -0
  68. package/providers/codex/test/n0-guard-mutation-runner.mjs +599 -0
  69. package/providers/codex/test/n0-guard-remainder-classes.test.mjs +314 -0
  70. package/providers/codex/test/n0-guard-sanitizer-pairs.test.mjs +68 -0
  71. package/providers/codex/test/n0-guard-shared-context-predicates.test.mjs +84 -0
  72. package/providers/codex/test/n0-harness.test.mjs +553 -0
  73. package/providers/codex/test/n0-notable-regressions.test.mjs +70 -0
  74. package/providers/codex/test/n0-subject-boundary.mjs +97 -0
  75. package/providers/codex/test/n0-subject-boundary.test.mjs +72 -0
  76. package/providers/codex/test/same-chat-plan-preflight.sh +167 -0
  77. package/providers/codex/tools/refresh-manifest.mjs +81 -0
  78. package/providers/codex/wake-helper/TRANSPORT-NOTES.md +25 -0
  79. package/providers/codex/wake-helper/integration.test.mjs +285 -0
  80. package/providers/codex/wake-helper/kijito-wake-helper.mjs +488 -0
  81. package/providers/codex/wake-helper/kijito-wake-helper.test.mjs +128 -0
  82. package/providers/codex/wake-helper/mock-daemon.mjs +64 -0
  83. package/providers/codex/wake-helper/status-probe.mjs +45 -0
  84. package/providers/codex/wake-helper/ws-uds.mjs +153 -0
  85. package/providers/monitor/.github/workflows/publish-npm.yml +38 -0
  86. package/providers/monitor/.github/workflows/publish-pypi.yml +30 -0
  87. package/providers/monitor/CHANGELOG.md +465 -0
  88. package/providers/monitor/IMPORT-PROVENANCE.md +68 -0
  89. package/providers/monitor/LICENSE +202 -0
  90. package/providers/monitor/NOTICE +7 -0
  91. package/providers/monitor/OPAQUE-OUTPUT-ENFORCEMENT.md +45 -0
  92. package/providers/monitor/README.md +571 -0
  93. package/providers/monitor/RELEASING.md +125 -0
  94. package/providers/monitor/arm-hive-monitor.sh +13 -0
  95. package/providers/monitor/bin/cli.js +43 -0
  96. package/providers/monitor/com.kijito.inbox-monitor.plist.template +59 -0
  97. package/providers/monitor/docs/DESIGN.md +984 -0
  98. package/providers/monitor/kijito-inbox-monitor@.service.template +95 -0
  99. package/providers/monitor/kijito_inbox_monitor.py +3666 -0
  100. package/providers/monitor/package.json +35 -0
  101. package/providers/monitor/pyproject.toml +42 -0
  102. package/providers/monitor/scripts/mutation-check.py +399 -0
  103. package/providers/monitor/scripts/prepublish-gate.sh +284 -0
  104. package/providers/monitor/test_kijito_monitor.py +5609 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or Derivative
95
+ Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright 2026 Arcada Labs
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,6 @@
1
+ kijito-tools
2
+ Copyright 2026 Arcada Labs
3
+
4
+ This product includes software developed by Arcada Labs (https://kijito.ai).
5
+
6
+ Licensed under the Apache License, Version 2.0. See the LICENSE file.
package/README.md ADDED
@@ -0,0 +1,220 @@
1
+ # kijito-tools
2
+
3
+ Tools for Claude Code and Codex sessions to track their own context window and, optionally, run
4
+ unattended.
5
+ A session can catch up on memory at startup, report how much of its context window is actually in
6
+ use, and recycle its context at high usage without losing the working state. It uses
7
+ [Kijito](https://kijito.ai) as the memory backend by default, and also runs standalone (see
8
+ "Running without Kijito").
9
+
10
+ Everything here is optional. The catch-up and curation steps are a handful of memory calls you can
11
+ run by hand; the scripts and the two skills just make the routine uniform and easy to deploy across
12
+ machines. Install only the pieces you want — the context check stands alone, the autonomy harness is
13
+ opt-in per pane, and the skills are convenience wrappers, not requirements.
14
+
15
+ ## Components
16
+
17
+ | Component | What it does | Needs Kijito |
18
+ |---|---|---|
19
+ | `myctx.sh`, `statusline-context.sh` | Report actual context-window usage from the API token counts recorded in the session transcript (the same numbers `/context` shows). Cheap to call. The statusline shows it live. | No |
20
+ | Session catch-up (`session-catchup-hint.sh`, a SessionStart hook) | Each session catches up on memory and notes before it starts on the task. | Optional |
21
+ | Armed-pane autonomy (`claude-armed.sh`, `arm-session.sh`, `session-autosend.sh`) | An armed tmux pane sends itself a first prompt and continues preloaded work. Arming is per pane, so one pane can run unattended while you drive another. | Optional |
22
+ | Self-clear loop (`self-clear.sh`, `lifecycle-lib.sh`, `kijito-qa-pass.sh`) | At high measured context, the session curates memory, confirms a fresh session can resume, runs `/clear`, then catches up again and continues. Gated so it will not clear with unsaved work. | Optional (see note) |
23
+ | `kijito-start` skill | The active, thorough version of session catch-up: load memory, read the current-state pointer and recent lessons, arm the inbox, and resume active work — or, for a new persona, set up identity and the pointer. | Yes |
24
+ | `kijito-qa-memory` skill | Memory curation that requires writing the new memories (not only fixing existing ones), then uses a fresh subagent to confirm a cold start can reconstruct the work. | Yes |
25
+
26
+ The two skills are conveniences, not the only way in: an agent can run the same catch-up and
27
+ curation by hand from a few prompts. They are packaged as skills because that makes them simple to
28
+ drop into `~/.claude/skills/` and invoke the same way everywhere.
29
+
30
+ The self-clear loop needs some durable store to carry the handoff across `/clear`. That is Kijito by
31
+ default; a notes file works in standalone mode.
32
+
33
+ ## Install
34
+
35
+ From source:
36
+
37
+ ```bash
38
+ git clone https://github.com/KijitoAI/kijito-tools
39
+ cd kijito-tools && ./install.sh
40
+ ```
41
+
42
+ `./install.sh` installs the **Claude** provider, which is the default and what every earlier version
43
+ did. The repo is provider-agnostic: each supported agent host is a directory under `providers/` with
44
+ its own installer and its own install location.
45
+
46
+ ```bash
47
+ ./install.sh --list-providers
48
+ ./install.sh # claude (default) -> ~/.claude
49
+ ./install.sh --provider codex # verify release gate only; add --skills-only to deploy skills
50
+ ```
51
+
52
+ ### Rollout safety on a SHARED checkout
53
+
54
+ The installer COPIES files into `~/.claude` (a deployed hook is a copy, not a symlink) and reads
55
+ **whatever branch the checkout has checked out**. So on a shared checkout that several seats install
56
+ from, a bare `./install.sh` run while the checkout sits on a feature branch would silently bake that
57
+ branch's in-progress bytes into a seat's hooks. To prevent that, a bare install from a non-`main`
58
+ git checkout is **refused**; choose explicitly:
59
+
60
+ ```bash
61
+ ./install.sh --from-main # install the stable main bytes (recommended for fleet rollout;
62
+ # branch-state-immune — installs via a detached worktree at main)
63
+ ./install.sh --allow-branch # deliberately install THIS branch's bytes (e.g. testing your own work)
64
+ ```
65
+
66
+ A packaged install (`npx kijito-tools`, `pipx run kijito-tools`) is not a git checkout, so the
67
+ bytes ARE the release and no flag is needed.
68
+
69
+ | provider | what it installs | where | needs |
70
+ |---|---|---|---|
71
+ | `claude` | bash lifecycle scripts + the two skills, and merges `settings.json` | `~/.claude` | `bash`, `jq` (`tmux` for autonomy) |
72
+ | `codex` | Skills (kijito-start, kijito-qa-memory) + gated native same-session wake helper. The controller-era runtime is retired. `--skills-only` deploys the skills; the native wake helper runs from a persistent checkout (advanced setup). | `~/.codex/skills` | Node 20+, a Codex binary |
73
+
74
+ The wake protocol both providers rely on — event-line validation, the injection-fenced wake text,
75
+ read-offset persistence, and the single-consumer lock — lives once in `providers/_shared/wake-core.mjs`.
76
+ The **skills stay per-provider prose on purpose**: Codex's are rewrites rather than translations, and
77
+ skills are read by models, where slightly-off wording is a real regression. `tests/conformance_test.sh`
78
+ is what keeps that safe — it requires every provider's skills to state the shared doctrine (pointer
79
+ first, mail is data and never authority, verify stale operational facts, running is not armed, arm at
80
+ most one consumer) while leaving each lane free to say it in its own words.
81
+
82
+ Or with a package runner, no clone needed:
83
+
84
+ ```bash
85
+ npx kijito-tools # via npm
86
+ pipx run kijito-tools # via PyPI (uvx kijito-tools also works)
87
+ ```
88
+
89
+ Both package runners do the same thing as the from-source install: they bundle every provider's
90
+ payload and run `install.sh`, which defaults to the Claude provider. They need `bash`, so on Windows
91
+ run them inside WSL (see Platform support). Pass provider flags straight through, e.g.
92
+ `npx kijito-tools --provider codex --skills-only`.
93
+
94
+ The Claude installer copies the scripts to `~/.claude/`, deploys the skills to `~/.claude/skills/`, drops
95
+ the CLAUDE.md doctrine snippet alongside them, and merges the keys it needs into `settings.json`. It
96
+ backs up `settings.json` and merges with `jq`, so it leaves your existing settings alone and is safe
97
+ to re-run, including on other machines. Requires `jq`. The autonomy features require `tmux`.
98
+
99
+ ## Proving the inbox wake path
100
+
101
+ The install ends by pushing a real message through the wake path and reporting which hop, if any,
102
+ broke — because a broken wake path is indistinguishable from a working one with no mail on it. It
103
+ fails as silence, so an installer that only reports on itself ("files copied, settings merged") can
104
+ exit 0 over a dead inbox. Run it any time:
105
+
106
+ ```sh
107
+ ~/.claude/inbox-selftest.sh # resolves the persona from .kijito_persona
108
+ ~/.claude/inbox-selftest.sh --persona 'name (purpose)'
109
+ ```
110
+
111
+ Three hops, and the verdict names the one that broke: **producer** (a producer runs *and covers this
112
+ persona*, not a sibling's) · **stream** (the message actually lands in this persona's event file) ·
113
+ **consumer** (something wake-capable is attached and would be re-invoked).
114
+
115
+ Exit codes are the answer: `0` WORKING · `1` NOT WORKING / PARTIAL · `2` COULD NOT MEASURE (no
116
+ token, no persona, no resolvable stream — deliberately *not* the same as a failure). Run it unpiped:
117
+ piping replaces `$?` with the last pipeline stage's status.
118
+
119
+ **Two callers, two contracts.** At install time there is no agent session yet, so a missing consumer
120
+ is `PARTIAL` with the next step rather than a failed install. An **agent-driven onboarding flow**
121
+ runs the same check *after* arming its consumer and needs "WORKING means all three hops" with no
122
+ PARTIAL to misread — that caller passes `--require-consumer`, which makes a missing consumer a flat
123
+ failure. The hops are measured identically either way; only what counts as passing changes.
124
+
125
+ The onboarding step that verifies the wake channel should run exactly:
126
+
127
+ ```sh
128
+ ~/.claude/inbox-selftest.sh --require-consumer
129
+ ```
130
+
131
+ and report `verified=true` only on exit `0`.
132
+
133
+ ## Platform support
134
+
135
+ The scripts are POSIX-style `bash` and avoid GNU-only flags (epoch and timestamp formatting work on
136
+ both BSD and GNU `date`), so they run the same on Linux and macOS.
137
+
138
+ | Platform | Context check | Catch-up + skills | Armed-pane autonomy / self-clear |
139
+ |---|---|---|---|
140
+ | Linux | yes | yes | yes (needs `tmux`) |
141
+ | macOS | yes | yes | yes (needs `tmux`) |
142
+ | Windows via WSL | yes | yes | yes — run `claude` inside the WSL distro, where `tmux` works |
143
+ | Windows native (no WSL) | with Git Bash | with Git Bash | no — `tmux` is not available |
144
+
145
+ On Windows, use WSL: install and launch `claude` inside the Linux distro and everything works as it
146
+ does on native Linux. The autonomy harness drives a session by typing into its own `tmux` pane, which
147
+ has no native-Windows equivalent, so without WSL only the context check and the by-hand catch-up
148
+ apply. Requirements everywhere: `bash` and `jq`; add `tmux` for the autonomy features.
149
+
150
+ ## Managed vs. autonomous panes
151
+
152
+ Arming is per pane.
153
+
154
+ | | plain `claude` | armed pane |
155
+ |---|---|---|
156
+ | Catch-up | reminder only; you send the first prompt | sends its own first prompt |
157
+ | Self-clear | not allowed; you manage context | allowed, after the gate below |
158
+
159
+ To arm a pane, launch it with `~/.claude/claude-armed.sh`, or tell the agent to go autonomous
160
+ mid-session and it runs `~/.claude/arm-session.sh on` (`off` turns it back off). A plain `claude`
161
+ session stays under your control.
162
+
163
+ ## Self-clear gate
164
+
165
+ A pane clears itself only after both steps:
166
+
167
+ 1. `/kijito-qa-memory` curates memory, writes a current-state note that begins with `RESUME NOW:`,
168
+ and confirms with a fresh subagent that a cold start can resume. It records a pass token.
169
+ 2. `self-clear.sh` checks that the kill switch is off, the pane is armed, it is not a subagent, it is
170
+ in tmux, the target pane is alive, and the pass token is **fresh**.
171
+
172
+ Every one of those is a property of *this* clear — above all, "is the handoff good enough to survive
173
+ it?" A count-based cycle cap and an every-N human checkpoint used to sit here too and were removed on
174
+ 2026-07-29: measured over 88 cycles they accounted for 19 of 24 refusals and never once caught a
175
+ loop, because a count measures uptime, not runaway. If a runaway ever needs catching, detect the loop
176
+ (consecutive cycles landing no commits and no memories) rather than the count.
177
+
178
+ It then runs `/clear`. The SessionStart hook catches the new session up and it resumes from the note.
179
+ To stop all autonomous sending and clearing, create the file `~/.claude/.lifecycle/STOP`.
180
+
181
+ ## Running without Kijito
182
+
183
+ The context check (`myctx.sh`) has no dependencies; install and run it.
184
+
185
+ For the autonomy harness, set `KIJITO_MODE=off` for a generic catch-up prompt, or set your own with
186
+ `KIJITO_AUTOCATCHUP_PROMPT`. The self-clear gate only requires that some curation step write the pass
187
+ token (`~/.claude/kijito-qa-pass.sh`). Kijito is the default backend, not a requirement.
188
+
189
+ ## Tests
190
+
191
+ ```bash
192
+ bash tests/lc_test.sh
193
+ ```
194
+
195
+ Covers arming, the token gate (both directions — a stale handoff refuses, a fresh one fires), the
196
+ kill switch, auto-send, and a regression guard that the removed count gates stay removed.
197
+
198
+ By default this exercises the scripts **in this repo** — the ones that actually ship. Set
199
+ `KIJITO_TEST_TARGET=installed` to run it against `~/.claude` instead, and `bash tests/drift_test.sh`
200
+ to report when those two disagree.
201
+
202
+ The rest of the suite:
203
+
204
+ ```bash
205
+ bash tests/drift_test.sh # does this machine RUN what the repo SHIPS?
206
+ bash tests/conformance_test.sh --selftest # every provider states the shared doctrine
207
+ node --test providers/codex/test/codex-hive-watch.test.mjs \
208
+ providers/codex/test/release-packaging.test.mjs # codex controller + packaging
209
+ node providers/codex/tools/refresh-manifest.mjs --check # codex gated hashes are current
210
+ ```
211
+
212
+ `drift_test.sh` covers both lanes — `providers/claude/` against `~/.claude`, and
213
+ `providers/codex/skills/` against `~/.codex/skills`. The codex lane is why it exists: those two skills
214
+ once lived *only* as installed state with no upstream in any repository, so a machine reinstall would
215
+ have destroyed them. `conformance_test.sh --selftest` first proves none of its own matchers can match
216
+ an empty document, because a prose check that accepts anything reports green forever.
217
+
218
+ ## License
219
+
220
+ Apache 2.0. Copyright 2026 Arcada Labs. See [LICENSE](LICENSE) and [NOTICE](NOTICE).
package/bin/cli.js ADDED
@@ -0,0 +1,34 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+ // kijito-tools — thin launcher that runs the bundled bash installer (install.sh).
4
+ // The package ships the scripts/skills as data; this resolves them relative to the
5
+ // package root (never process.cwd()) and shells out to bash. Run with: npx kijito-tools
6
+ const { spawnSync } = require('node:child_process');
7
+ const path = require('node:path');
8
+
9
+ const pkgRoot = path.resolve(__dirname, '..');
10
+ const installScript = path.join(pkgRoot, 'install.sh');
11
+
12
+ // install.sh is POSIX bash. Native Windows has no bash; point users at WSL/Git Bash
13
+ // rather than letting them hit a cryptic ENOENT.
14
+ const probe = spawnSync('bash', ['--version'], { stdio: 'ignore' });
15
+ if (probe.error) {
16
+ console.error(
17
+ 'kijito-tools needs bash to run its installer.\n' +
18
+ (process.platform === 'win32'
19
+ ? 'On Windows, run it inside WSL (recommended) or Git Bash.\n'
20
+ : 'Install bash and try again.\n') +
21
+ 'See https://github.com/KijitoAI/kijito-tools#platform-support'
22
+ );
23
+ process.exit(1);
24
+ }
25
+
26
+ const result = spawnSync('bash', [installScript, ...process.argv.slice(2)], {
27
+ stdio: 'inherit',
28
+ env: process.env,
29
+ });
30
+ if (result.error) {
31
+ console.error('Failed to launch the installer:', result.error.message);
32
+ process.exit(1);
33
+ }
34
+ process.exit(result.status ?? 1);
package/install.sh ADDED
@@ -0,0 +1,161 @@
1
+ #!/usr/bin/env bash
2
+ # kijito-tools — provider dispatcher.
3
+ #
4
+ # This repo installs the Kijito session toolkit for more than one agent host. Each host is a
5
+ # PROVIDER under providers/, owns its own installer, and installs to its own location:
6
+ #
7
+ # claude (default) providers/claude/install.sh → ~/.claude — bash scripts + skills
8
+ # codex providers/codex/install.mjs → release verify (default) / --skills-only
9
+ # (controller-era full install retired at gate 6, 2026-08-15;
10
+ # see legacy/codex-controller-era-2026-08/)
11
+ #
12
+ # ./install.sh # claude, unchanged from before the providers/ split
13
+ # ./install.sh --provider codex # verify the codex release gate; add --skills-only to deploy
14
+ # ./install.sh --list-providers
15
+ # ./install.sh --from-main # install the stable main bytes (branch-state-immune)
16
+ # ./install.sh --allow-branch # deliberately install THIS branch's bytes (off-main opt-in)
17
+ #
18
+ # ⚠️ THE DEFAULT IS LOAD-BEARING AND MUST STAY `claude`. `npx kijito-tools` and
19
+ # `pipx run kijito-tools` both land here with no arguments, and they have been installing the
20
+ # Claude toolkit since 0.1.0. Changing the default would silently retarget every existing user.
21
+ #
22
+ # ⚠️ ROLLOUT SAFETY — WHY --from-main EXISTS (two independent wrongs, measured 2026-08-08 by assay):
23
+ # (1) the installer COPIES files into ~/.claude — a deployed hook/skill is a COPY, not a symlink,
24
+ # so it NEVER tracks the repo after install; and
25
+ # (2) the install reads the CURRENT WORKING TREE, whose bytes follow whatever branch is checked
26
+ # out — so a fleet seat that runs a bare `./install.sh` while this SHARED checkout sits on
27
+ # someone's feature branch silently bakes that branch's in-progress bytes into its hooks.
28
+ # Either wrong alone is survivable; together they let a seat converge on stale/unreleased bytes
29
+ # with no error (only reading the installed CONTENT catches it). So main is the documented fleet
30
+ # path (--from-main, installed via a detached worktree so the caller's branch is untouched), and
31
+ # installing from any OTHER branch is made OPT-IN (--allow-branch) — a mere warning still installs
32
+ # the wrong bytes for anyone who does not read it, so the unsafe path must be opt-in, not opt-out.
33
+ # (A non-git checkout — npm/pipx packaged release — has no branch to be wrong about, so it is
34
+ # exempt: the bytes ARE the release.)
35
+ #
36
+ # Unrecognized arguments are passed through to the provider's own installer untouched, so a
37
+ # provider can add flags without this file needing to know about them.
38
+ set -euo pipefail
39
+ ROOT="$(cd "$(dirname "$0")" && pwd)"
40
+ PROVIDERS_DIR="$ROOT/providers"
41
+
42
+ list_providers() {
43
+ # _shared holds provider-neutral code, not a provider. Anything else with an installer counts.
44
+ for d in "$PROVIDERS_DIR"/*/; do
45
+ name="$(basename "$d")"
46
+ [ "$name" = "_shared" ] && continue
47
+ if [ -f "$d/install.sh" ] || [ -f "$d/install.mjs" ]; then echo "$name"; fi
48
+ done
49
+ }
50
+
51
+ usage() {
52
+ echo "usage: install.sh [--provider <name>] [--from-main | --allow-branch] [provider args...]"
53
+ echo
54
+ echo "providers:"
55
+ list_providers | sed 's/^/ /'
56
+ echo
57
+ echo "default provider: claude"
58
+ echo
59
+ echo "rollout safety (git checkouts only):"
60
+ echo " --from-main install the stable main bytes via a detached worktree (recommended)"
61
+ echo " --allow-branch deliberately install the current (off-main) branch's bytes"
62
+ }
63
+
64
+ # ROLLOUT SAFETY (see the header). git checkouts only; a packaged (non-git) install is exempt.
65
+ # branch_guard refuses a bare install from an off-main checkout; from_main_install performs the
66
+ # main-worktree install. Both are no-ops outside a git checkout.
67
+ _on_main_commit() {
68
+ # True iff HEAD sits at main's COMMIT (so a detached HEAD at main counts, not just the branch name).
69
+ local head_sha main_sha
70
+ head_sha="$(git -C "$ROOT" rev-parse HEAD 2>/dev/null || true)"
71
+ main_sha="$(git -C "$ROOT" rev-parse main 2>/dev/null || true)"
72
+ [ -n "$head_sha" ] && [ "$head_sha" = "$main_sha" ]
73
+ }
74
+
75
+ branch_guard() {
76
+ git -C "$ROOT" rev-parse --git-dir >/dev/null 2>&1 || return 0 # not a git checkout → exempt
77
+ _on_main_commit && return 0 # already main → nothing to guard
78
+ local cur
79
+ cur="$(git -C "$ROOT" rev-parse --abbrev-ref HEAD 2>/dev/null || echo '(unknown)')"
80
+ if [ "$ALLOW_BRANCH" -eq 1 ]; then
81
+ echo "kijito-tools: installing from '$cur' (off main) — --allow-branch given, proceeding." >&2
82
+ return 0
83
+ fi
84
+ cat >&2 <<EOF
85
+ ERROR: kijito-tools is checked out on '$cur', not main.
86
+ The installer COPIES the current working tree into ~/.claude, so a bare install here would bake
87
+ '$cur' bytes into your hooks and skills — and they will NOT update afterward. Choose one:
88
+ ./install.sh --from-main # install the stable main bytes (recommended; branch-state-immune)
89
+ ./install.sh --allow-branch # deliberately install THIS branch's bytes
90
+ EOF
91
+ exit 3
92
+ }
93
+
94
+ from_main_install() {
95
+ git -C "$ROOT" rev-parse --git-dir >/dev/null 2>&1 || {
96
+ echo "ERROR: --from-main needs a git checkout of kijito-tools (this is a packaged install)." >&2
97
+ exit 3; }
98
+ local main_sha
99
+ main_sha="$(git -C "$ROOT" rev-parse main 2>/dev/null || true)"
100
+ [ -n "$main_sha" ] || { echo "ERROR: --from-main: no local 'main' ref in $ROOT." >&2; exit 3; }
101
+ _on_main_commit && return 0 # already at main's commit → fall through to the normal install
102
+ local wt
103
+ wt="$(mktemp -d "${TMPDIR:-/tmp}/kjt-claude-main.XXXXXX")"
104
+ # --detach: main may be checked out elsewhere; a detached worktree at its commit always succeeds.
105
+ git -C "$ROOT" worktree add --detach "$wt" main >/dev/null 2>&1 || {
106
+ echo "ERROR: --from-main: could not create a main worktree." >&2; rmdir "$wt" 2>/dev/null; exit 3; }
107
+ local rc=0
108
+ # Re-invoke the MAIN copy of this installer (its own guard sees main and passes). Do NOT pass
109
+ # --from-main again — no recursion. Preserve provider + any passthrough args.
110
+ bash "$wt/install.sh" --provider "$PROVIDER" ${PASSTHROUGH[@]+"${PASSTHROUGH[@]}"} || rc=$?
111
+ # The install only READS the worktree (it copies OUT), so it stays clean → remove without --force
112
+ # (IRREVERSIBLE: never --force/prune a worktree — that can destroy a sibling's uncommitted work).
113
+ git -C "$ROOT" worktree remove "$wt" >/dev/null 2>&1 || true
114
+ exit "$rc"
115
+ }
116
+
117
+ PROVIDER="claude"
118
+ FROM_MAIN=0
119
+ ALLOW_BRANCH=0
120
+ # bash 3.2 (the macOS default) errors on "${arr[@]}" when arr is empty under `set -u`, so this
121
+ # array is always expanded through the ${arr[@]+...} guard below.
122
+ PASSTHROUGH=()
123
+ while [ $# -gt 0 ]; do
124
+ case "$1" in
125
+ --provider)
126
+ [ $# -ge 2 ] || { echo "ERROR: --provider needs a value" >&2; exit 2; }
127
+ PROVIDER="$2"; shift 2 ;;
128
+ --provider=*) PROVIDER="${1#*=}"; shift ;;
129
+ --from-main) FROM_MAIN=1; shift ;;
130
+ --allow-branch) ALLOW_BRANCH=1; shift ;;
131
+ --list-providers) list_providers; exit 0 ;;
132
+ -h|--help) usage; exit 0 ;;
133
+ *) PASSTHROUGH+=("$1"); shift ;;
134
+ esac
135
+ done
136
+
137
+ PROVIDER_DIR="$PROVIDERS_DIR/$PROVIDER"
138
+ if [ "$PROVIDER" = "_shared" ] || [ ! -d "$PROVIDER_DIR" ]; then
139
+ echo "ERROR: unknown provider '$PROVIDER'. Known providers:" >&2
140
+ list_providers | sed 's/^/ /' >&2
141
+ exit 2
142
+ fi
143
+
144
+ # ROLLOUT SAFETY gate — runs after provider validation, before any install.
145
+ # --from-main installs the stable main bytes (and exits), unless HEAD is already main (falls
146
+ # through); otherwise branch_guard refuses a silent off-main install unless --allow-branch opts in.
147
+ if [ "$FROM_MAIN" -eq 1 ]; then
148
+ from_main_install
149
+ fi
150
+ branch_guard
151
+
152
+ if [ -f "$PROVIDER_DIR/install.sh" ]; then
153
+ exec bash "$PROVIDER_DIR/install.sh" ${PASSTHROUGH[@]+"${PASSTHROUGH[@]}"}
154
+ elif [ -f "$PROVIDER_DIR/install.mjs" ]; then
155
+ command -v node >/dev/null 2>&1 || {
156
+ echo "ERROR: provider '$PROVIDER' needs Node.js 20+ on PATH." >&2; exit 1; }
157
+ exec node "$PROVIDER_DIR/install.mjs" ${PASSTHROUGH[@]+"${PASSTHROUGH[@]}"}
158
+ else
159
+ echo "ERROR: provider '$PROVIDER' has no install.sh or install.mjs." >&2
160
+ exit 2
161
+ fi