@crouton-kit/crouter 0.3.11 → 0.3.12

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 (182) hide show
  1. package/bin/crtrd +2 -0
  2. package/dist/builtin-personas/design/base.md +9 -0
  3. package/dist/builtin-personas/design/orchestrator.md +10 -0
  4. package/dist/builtin-personas/developer/base.md +9 -0
  5. package/dist/builtin-personas/developer/orchestrator.md +12 -0
  6. package/dist/builtin-personas/explore/base.md +9 -0
  7. package/dist/builtin-personas/explore/orchestrator.md +9 -0
  8. package/dist/builtin-personas/general/base.md +5 -0
  9. package/dist/builtin-personas/general/orchestrator.md +7 -0
  10. package/dist/builtin-personas/orchestration-kernel.md +71 -0
  11. package/dist/builtin-personas/plan/base.md +7 -0
  12. package/dist/builtin-personas/plan/orchestrator.md +12 -0
  13. package/dist/builtin-personas/review/base.md +7 -0
  14. package/dist/builtin-personas/review/orchestrator.md +9 -0
  15. package/dist/builtin-personas/runtime-base.md +39 -0
  16. package/dist/builtin-personas/spec/base.md +7 -0
  17. package/dist/builtin-personas/spec/orchestrator.md +10 -0
  18. package/dist/builtin-skills/skills/design/SKILL.md +51 -0
  19. package/dist/builtin-skills/skills/development/SKILL.md +109 -0
  20. package/dist/builtin-skills/skills/planning/SKILL.md +59 -0
  21. package/dist/builtin-skills/skills/spec/SKILL.md +83 -0
  22. package/dist/cli.js +14 -6
  23. package/dist/commands/{mode.d.ts → attention.d.ts} +1 -1
  24. package/dist/commands/attention.js +152 -0
  25. package/dist/commands/canvas.d.ts +2 -0
  26. package/dist/commands/canvas.js +35 -0
  27. package/dist/commands/daemon.d.ts +2 -0
  28. package/dist/commands/daemon.js +111 -0
  29. package/dist/commands/dashboard.d.ts +2 -0
  30. package/dist/commands/dashboard.js +65 -0
  31. package/dist/commands/human/prompts.d.ts +5 -0
  32. package/dist/commands/human/prompts.js +269 -0
  33. package/dist/commands/human/queue.d.ts +3 -0
  34. package/dist/commands/human/queue.js +133 -0
  35. package/dist/commands/human/shared.d.ts +43 -0
  36. package/dist/commands/human/shared.js +107 -0
  37. package/dist/commands/human.js +10 -454
  38. package/dist/commands/node.d.ts +2 -0
  39. package/dist/commands/node.js +354 -0
  40. package/dist/commands/pkg/market-inspect.d.ts +1 -0
  41. package/dist/commands/pkg/market-inspect.js +157 -0
  42. package/dist/commands/pkg/market-manage.d.ts +1 -0
  43. package/dist/commands/pkg/market-manage.js +316 -0
  44. package/dist/commands/pkg/market.d.ts +1 -0
  45. package/dist/commands/pkg/market.js +16 -0
  46. package/dist/commands/pkg/plugin-inspect.d.ts +1 -0
  47. package/dist/commands/pkg/plugin-inspect.js +142 -0
  48. package/dist/commands/pkg/plugin-manage.d.ts +1 -0
  49. package/dist/commands/pkg/plugin-manage.js +294 -0
  50. package/dist/commands/pkg/plugin.d.ts +1 -0
  51. package/dist/commands/pkg/plugin.js +16 -0
  52. package/dist/commands/pkg/shared.d.ts +5 -0
  53. package/dist/commands/pkg/shared.js +61 -0
  54. package/dist/commands/pkg.js +3 -1004
  55. package/dist/commands/push.d.ts +3 -0
  56. package/dist/commands/push.js +159 -0
  57. package/dist/commands/revive.d.ts +2 -0
  58. package/dist/commands/revive.js +64 -0
  59. package/dist/commands/skill/author.d.ts +3 -0
  60. package/dist/commands/skill/author.js +147 -0
  61. package/dist/commands/skill/find.d.ts +4 -0
  62. package/dist/commands/skill/find.js +254 -0
  63. package/dist/commands/skill/read.d.ts +1 -0
  64. package/dist/commands/skill/read.js +89 -0
  65. package/dist/commands/skill/shared.d.ts +19 -0
  66. package/dist/commands/skill/shared.js +207 -0
  67. package/dist/commands/skill/state.d.ts +3 -0
  68. package/dist/commands/skill/state.js +69 -0
  69. package/dist/commands/skill.js +6 -691
  70. package/dist/commands/sys/config.d.ts +1 -0
  71. package/dist/commands/sys/config.js +186 -0
  72. package/dist/commands/sys/doctor.d.ts +1 -0
  73. package/dist/commands/sys/doctor.js +369 -0
  74. package/dist/commands/sys/shared.d.ts +3 -0
  75. package/dist/commands/sys/shared.js +24 -0
  76. package/dist/commands/sys/update.d.ts +2 -0
  77. package/dist/commands/sys/update.js +114 -0
  78. package/dist/commands/sys.js +4 -694
  79. package/dist/core/__tests__/argv-parser.test.js +19 -1
  80. package/dist/core/__tests__/canvas-inbox-watcher.test.js +100 -0
  81. package/dist/core/__tests__/canvas.test.js +154 -0
  82. package/dist/core/__tests__/reset.test.js +105 -0
  83. package/dist/core/canvas/attention.d.ts +24 -0
  84. package/dist/core/canvas/attention.js +94 -0
  85. package/dist/core/canvas/canvas.d.ts +40 -0
  86. package/dist/core/canvas/canvas.js +210 -0
  87. package/dist/core/canvas/db.d.ts +7 -0
  88. package/dist/core/canvas/db.js +61 -0
  89. package/dist/core/canvas/index.d.ts +4 -0
  90. package/dist/core/canvas/index.js +6 -0
  91. package/dist/core/canvas/paths.d.ts +16 -0
  92. package/dist/core/canvas/paths.js +62 -0
  93. package/dist/core/canvas/render.d.ts +30 -0
  94. package/dist/core/canvas/render.js +186 -0
  95. package/dist/core/canvas/types.d.ts +87 -0
  96. package/dist/core/canvas/types.js +8 -0
  97. package/dist/core/command.d.ts +5 -0
  98. package/dist/core/command.js +35 -10
  99. package/dist/core/feed/feed.d.ts +43 -0
  100. package/dist/core/feed/feed.js +116 -0
  101. package/dist/core/feed/inbox.d.ts +50 -0
  102. package/dist/core/feed/inbox.js +124 -0
  103. package/dist/core/help.js +5 -3
  104. package/dist/core/io.d.ts +15 -1
  105. package/dist/core/io.js +56 -6
  106. package/dist/core/personas/index.d.ts +12 -0
  107. package/dist/core/personas/index.js +10 -0
  108. package/dist/core/personas/loader.d.ts +44 -0
  109. package/dist/core/personas/loader.js +157 -0
  110. package/dist/core/personas/resolve.d.ts +36 -0
  111. package/dist/core/personas/resolve.js +110 -0
  112. package/dist/core/render.d.ts +11 -0
  113. package/dist/core/render.js +126 -0
  114. package/dist/core/resolver.d.ts +10 -0
  115. package/dist/core/resolver.js +109 -1
  116. package/dist/core/runtime/front-door.d.ts +10 -0
  117. package/dist/core/runtime/front-door.js +97 -0
  118. package/dist/core/runtime/kickoff.d.ts +23 -0
  119. package/dist/core/runtime/kickoff.js +134 -0
  120. package/dist/core/runtime/launch.d.ts +34 -0
  121. package/dist/core/runtime/launch.js +85 -0
  122. package/dist/core/runtime/nodes.d.ts +38 -0
  123. package/dist/core/runtime/nodes.js +95 -0
  124. package/dist/core/runtime/presence.d.ts +38 -0
  125. package/dist/core/runtime/presence.js +152 -0
  126. package/dist/core/runtime/promote.d.ts +30 -0
  127. package/dist/core/runtime/promote.js +105 -0
  128. package/dist/core/runtime/reset.d.ts +13 -0
  129. package/dist/core/runtime/reset.js +97 -0
  130. package/dist/core/runtime/revive.d.ts +26 -0
  131. package/dist/core/runtime/revive.js +89 -0
  132. package/dist/core/runtime/roadmap.d.ts +12 -0
  133. package/dist/core/runtime/roadmap.js +52 -0
  134. package/dist/core/runtime/spawn.d.ts +33 -0
  135. package/dist/core/runtime/spawn.js +118 -0
  136. package/dist/core/runtime/stop-guard.d.ts +18 -0
  137. package/dist/core/runtime/stop-guard.js +33 -0
  138. package/dist/core/runtime/tmux.d.ts +88 -0
  139. package/dist/core/runtime/tmux.js +198 -0
  140. package/dist/core/spawn.d.ts +17 -197
  141. package/dist/core/spawn.js +16 -539
  142. package/dist/daemon/crtrd-cli.js +4 -0
  143. package/dist/daemon/crtrd.d.ts +20 -0
  144. package/dist/daemon/crtrd.js +200 -0
  145. package/dist/daemon/manage.d.ts +17 -0
  146. package/dist/daemon/manage.js +57 -0
  147. package/dist/pi-extensions/canvas-inbox-watcher.d.ts +16 -0
  148. package/dist/pi-extensions/canvas-inbox-watcher.js +229 -0
  149. package/dist/pi-extensions/canvas-nav.d.ts +32 -0
  150. package/dist/pi-extensions/canvas-nav.js +536 -0
  151. package/dist/pi-extensions/canvas-stophook.d.ts +17 -0
  152. package/dist/pi-extensions/canvas-stophook.js +373 -0
  153. package/package.json +6 -5
  154. package/dist/commands/agent.d.ts +0 -6
  155. package/dist/commands/agent.js +0 -585
  156. package/dist/commands/debug.d.ts +0 -3
  157. package/dist/commands/debug.js +0 -192
  158. package/dist/commands/job.d.ts +0 -11
  159. package/dist/commands/job.js +0 -384
  160. package/dist/commands/mode.js +0 -231
  161. package/dist/commands/plan.d.ts +0 -4
  162. package/dist/commands/plan.js +0 -322
  163. package/dist/commands/spec.d.ts +0 -3
  164. package/dist/commands/spec.js +0 -299
  165. package/dist/core/__tests__/flow-leaves.test.js +0 -248
  166. package/dist/core/__tests__/job.test.js +0 -310
  167. package/dist/core/__tests__/jobs.test.js +0 -98
  168. package/dist/core/__tests__/spawn.test.js +0 -138
  169. package/dist/core/__tests__/subagents.test.d.ts +0 -1
  170. package/dist/core/__tests__/subagents.test.js +0 -75
  171. package/dist/core/jobs.d.ts +0 -107
  172. package/dist/core/jobs.js +0 -565
  173. package/dist/core/subagents.d.ts +0 -18
  174. package/dist/core/subagents.js +0 -163
  175. package/dist/prompts/agent.d.ts +0 -27
  176. package/dist/prompts/agent.js +0 -184
  177. package/dist/prompts/debug.d.ts +0 -8
  178. package/dist/prompts/debug.js +0 -44
  179. /package/dist/core/__tests__/{flow-leaves.test.d.ts → canvas-inbox-watcher.test.d.ts} +0 -0
  180. /package/dist/core/__tests__/{job.test.d.ts → canvas.test.d.ts} +0 -0
  181. /package/dist/core/__tests__/{jobs.test.d.ts → reset.test.d.ts} +0 -0
  182. /package/dist/{core/__tests__/spawn.test.d.ts → daemon/crtrd-cli.d.ts} +0 -0
@@ -1,217 +1,37 @@
1
- export interface SpawnAgentOptions {
2
- /** First user message for the new agent session. */
3
- prompt: string;
4
- cwd: string;
5
- /** crtr job_id injected as CRTR_JOB_ID env var in the pane. */
6
- jobId: string;
7
- /** If set, resume this Claude Code session with --fork-session (new session id). */
8
- fork?: {
9
- sessionId: string;
10
- };
11
- /** Max panes per tmux window before overflowing to a new window. */
12
- maxPanesPerWindow: number;
13
- /** Display name passed to the agent's `-n` flag; surfaces in pane title and resume picker. */
14
- name?: string;
15
- /** Persona appended via `--append-system-prompt` (subagent body). */
16
- systemPrompt?: string;
17
- /** Model pattern/id passed via `--model`. */
18
- model?: string;
19
- /** Tool allow-list passed to pi via `--tools`. */
20
- tools?: string[];
21
- }
22
- export interface SpawnAgentResult {
23
- status: 'spawned' | 'spawn-failed' | 'not-in-tmux';
24
- /** tmux pane id of the spawned pane. */
25
- paneId?: string;
26
- /** How the pane was placed. */
27
- placement?: 'split-window' | 'new-window';
28
- message: string;
29
- }
1
+ export declare function isInTmux(): boolean;
2
+ export declare function shellQuote(s: string): string;
3
+ /** Count panes in the current tmux window (0 outside tmux / on error). */
4
+ export declare function countPanesInCurrentWindow(): number;
5
+ /**
6
+ * Schedule a kill-pane on the *current* tmux pane after `delaySeconds`, detached
7
+ * so the caller can return normally before the pane dies. No-op outside tmux,
8
+ * when TMUX_PANE is unset, or when delaySeconds <= 0.
9
+ */
10
+ export declare function scheduleKillCurrentPane(delaySeconds: number): boolean;
30
11
  export interface DetachOptions {
31
- /** Inner command to run in the pane. If omitted, build the detected agent's
32
- * invocation around `<prompt>`. */
33
- command?: string;
34
- /** Full first user message for the new agent session (ignored when `command`
35
- * is set). No custom system prompt. */
36
- prompt?: string;
12
+ /** Inner command to run in the new pane. */
13
+ command: string;
37
14
  cwd: string;
38
- /** crtr job_id injected as CRTR_JOB_ID env var in the pane and used by the
39
- * `_fail` guard. Optional only when `failGuard` is false. */
15
+ /** Optional id injected as the CRTR_JOB_ID env var in the pane. */
40
16
  jobId?: string;
41
17
  /** Where to open the new pane. */
42
18
  placement: 'split-h' | 'split-v' | 'new-window';
43
- /** Seconds to wait before killing the originating pane so the caller can finish. */
19
+ /** Seconds before killing the originating pane so the caller can finish. */
44
20
  killAfterSeconds: number;
45
- /** Append `; crtr job _fail <jobId>` and inject CRTR_JOB_ID. Default true. */
46
- failGuard?: boolean;
47
21
  /** Pin the new pane to this tmux pane: split-window splits it; new-window is
48
22
  * inserted immediately after its window (-a -t <pane>). Without this, tmux
49
23
  * uses the attached client's currently-focused pane — which drifts if the
50
24
  * user switches windows between kickoff and spawn. */
51
25
  targetPane?: string;
52
- /** Display name passed to the agent's `-n` flag; ignored when `command` is set
53
- * (caller controls the full argv in that mode). */
54
- name?: string;
55
26
  }
56
27
  export interface DetachResult {
57
28
  status: 'spawned' | 'spawn-failed' | 'not-in-tmux';
58
29
  paneId?: string;
59
30
  message: string;
60
31
  }
61
- export declare function isInTmux(): boolean;
62
- export declare function shellQuote(s: string): string;
63
- /** Coding-agent CLIs crtr knows how to spawn as a sibling worker. */
64
- export type AgentKind = 'claude' | 'pi';
65
- /**
66
- * Detect which coding-agent CLI is hosting the current crtr process so spawns
67
- * launch a matching sibling. pi exports `PI_CODING_AGENT=true` into its tool
68
- * subprocess environment; Claude Code exports `CLAUDECODE` /
69
- * `CLAUDE_CODE_SESSION_ID`. Defaults to claude when no signal is present
70
- * (preserves prior behavior).
71
- */
72
- export declare function detectAgentKind(): AgentKind;
73
32
  /**
74
- * Normalize a `--model` value for the target agent CLI.
75
- *
76
- * Subagent frontmatter uses Claude Code's bare aliases (`sonnet`, `opus`,
77
- * `haiku`, optionally with a `:thinking` suffix). The `claude` CLI resolves
78
- * those natively, but `pi` maps a bare alias to its default provider —
79
- * `amazon-bedrock` — which most users have not authenticated, so the spawn
80
- * dies with "No API key found for amazon-bedrock". These aliases name Anthropic
81
- * models, so under pi we pin them to the `anthropic/` provider (preserving any
82
- * `:thinking` suffix). Values that already carry a `provider/` prefix or are
83
- * concrete model ids are passed through untouched.
84
- */
85
- export declare function normalizeModelForKind(model: string, kind: AgentKind): string;
86
- export interface AgentCommandOptions {
87
- /** First user message delivered to the new agent session. */
88
- prompt: string;
89
- /** Display name (`-n`); surfaces in the pane title and resume picker. */
90
- name?: string;
91
- /** Fork an existing session into a fresh one rather than starting clean. */
92
- fork?: {
93
- sessionId: string;
94
- };
95
- /** Persona/system prompt appended to the agent's default (`--append-system-prompt`).
96
- * Used to apply a subagent definition's body. */
97
- systemPrompt?: string;
98
- /** Model pattern/id passed via `--model` (both claude and pi). */
99
- model?: string;
100
- /** Tool allow-list. Passed to pi via `--tools`; ignored for claude, whose
101
- * tool names and gating flag differ. */
102
- tools?: string[];
103
- }
104
- /**
105
- * Build the agent-CLI invocation (no job wrapper) for the given kind.
106
- *
107
- * claude: `claude [-n <name>] [--resume <id> --fork-session] \
108
- * --dangerously-skip-permissions <prompt>`
109
- * pi: `pi [-n <name>] [--fork <id>] <prompt>`
110
- *
111
- * pi has no permission popups, so it needs no skip-permissions flag.
112
- */
113
- export declare function buildAgentCommand(opts: AgentCommandOptions, kind?: AgentKind): string;
114
- export interface AgentPrintArgv {
115
- cmd: string;
116
- args: string[];
117
- }
118
- /**
119
- * Argv for a non-interactive print-mode run.
120
- *
121
- * claude: `claude [-n <name>] [--resume <id> --fork-session] -p \
122
- * --dangerously-skip-permissions <prompt>`
123
- * pi: `pi [-n <name>] [--fork <id>] -p <prompt>`
124
- *
125
- * Returned as a cmd + args array so callers can spawn without a shell.
126
- */
127
- export declare function buildAgentPrintArgv(opts: AgentCommandOptions, kind?: AgentKind): AgentPrintArgv;
128
- /** Same as buildAgentPrintArgv but rendered as a single shell-quoted string. */
129
- export declare function buildAgentPrintCommand(opts: AgentCommandOptions, kind?: AgentKind): string;
130
- export interface HeadlessRunResult {
131
- status: 'done' | 'failed';
132
- /** Captured stdout on success; stdout+stderr (or an error message) on failure. */
133
- output: string;
134
- exitCode: number | null;
135
- }
136
- /**
137
- * Run the agent headlessly and resolve once it exits. A blocking caller awaits
138
- * this. stdout is captured as the result; a non-zero exit yields status
139
- * 'failed' with the combined output.
140
- */
141
- export declare function runAgentHeadless(opts: {
142
- prompt: string;
143
- name?: string;
144
- cwd: string;
145
- systemPrompt?: string;
146
- model?: string;
147
- tools?: string[];
148
- }): Promise<HeadlessRunResult>;
149
- export interface HeadlessDetachResult {
150
- status: 'spawned' | 'spawn-failed';
151
- pid?: number;
152
- message: string;
153
- }
154
- /**
155
- * Launch a headless agent detached (background). Its print output is captured
156
- * and delivered to the job via `crtr job submit`; a non-zero exit marks the job
157
- * failed. Returns immediately with the wrapper pid (recorded for crash
158
- * detection). No tmux required.
159
- */
160
- export declare function spawnHeadlessDetached(opts: {
161
- prompt: string;
162
- name?: string;
163
- cwd: string;
164
- jobId: string;
165
- systemPrompt?: string;
166
- model?: string;
167
- tools?: string[];
168
- }): HeadlessDetachResult;
169
- export declare function countPanesInCurrentWindow(): number;
170
- /**
171
- * Find a window in the current tmux session with fewer than `maxPanesPerWindow`
172
- * panes AND where every existing pane hosts an agent (claude or pi) as its
173
- * foreground process. Prefers the active window so the spawned pane is visible
174
- * to the user; otherwise falls back to the first other eligible window. Returns
175
- * the tmux window id (e.g. `@5`) to pass via `-t`, or null if no window qualifies.
176
- *
177
- * Windows holding non-agent panes (dashboards, log tails, idle shells, editors,
178
- * REPLs, etc.) are skipped so spawning never disrupts those workflows. A pane
179
- * qualifies as long as an agent comm is among its foreground commands —
180
- * co-resident helpers like `caffeinate` don't disqualify it.
181
- */
182
- export declare function findWindowWithSpace(maxPanesPerWindow: number): string | null;
183
- /**
184
- * Schedule a kill-pane on the *current* tmux pane after `delaySeconds`, detached
185
- * so the caller can return normally before the pane dies. No-op outside tmux
186
- * or when TMUX_PANE is unset.
187
- *
188
- * Used by `crtr job submit` (kill_pane=true) so a reviewer agent can self-close
189
- * its pane after delivering its verdict, and by `spawnAndDetach` for handoff
190
- * self-kill.
191
- */
192
- export declare function scheduleKillCurrentPane(delaySeconds: number): boolean;
193
- /**
194
- * Fire-and-forget: launch an interactive agent in a new pane (or window),
195
- * then schedule the originating pane to be killed after `killAfterSeconds`.
196
- *
197
- * No custom system prompt — the task is delivered as the first user message.
198
- * Returns as soon as the new pane is up; does NOT wait for the agent to finish.
33
+ * Fire-and-forget: launch `opts.command` in a new pane (or window), then
34
+ * schedule the originating pane to be killed after `killAfterSeconds`. Returns
35
+ * as soon as the new pane is up; does NOT wait for the command to finish.
199
36
  */
200
37
  export declare function spawnAndDetach(opts: DetachOptions): DetachResult;
201
- /** Originating pane id + session id of the host (pi/claude) crtr runs under. */
202
- export declare function originContext(): {
203
- pane: string;
204
- sessionId: string;
205
- } | null;
206
- /** Deterministic subagent session name for an originating pane id (e.g. `%5`). */
207
- export declare function subagentSessionName(pane: string): string;
208
- /**
209
- * Async sibling spawn. Launches an interactive agent (claude or pi, per
210
- * detectAgentKind) in the dedicated subagent session, progressively filling
211
- * windows up to `maxPanesPerWindow` before creating a new window. Returns
212
- * immediately with the pane id; the parent stays alive. Focus is never
213
- * switched — the user jumps to the subagent session with Alt-o.
214
- *
215
- * If `fork` is set, forks the host session into a fresh one.
216
- */
217
- export declare function spawnAgent(opts: SpawnAgentOptions): SpawnAgentResult;