@crouton-kit/crouter 0.1.4 → 0.1.7

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.
@@ -1,49 +1,435 @@
1
1
  export function skillPrompt() {
2
- return `# Skill workflow
2
+ return `# Skills — durable agent memory
3
3
 
4
- \`crtr\` ships skills markdown reference with frontmatter that you pull on
5
- demand. When the user's task matches a skill's description, run
6
- \`crtr skill show <name>\` and apply the guidance. Ambiguous names exit \`4\` —
7
- disambiguate with \`<plugin>:<name>\`.
4
+ Skills are markdown the agent loads on demand. **Audience: future LLM agent
5
+ sessions, not humans.** Write for the model: terse, decision-first, dense.
6
+ The CLI is the index \`crtr skill list/search/grep\` discovers what's saved.
7
+
8
+ Locations (resolution order):
9
+ 1. **Scope-direct** \`<scope-root>/skills/<name>/SKILL.md\` → \`user:<name>\` / \`project:<name>\`
10
+ 2. **Plugin skills** \`<plugin>/skills/<name>/SKILL.md\` → \`<scope>:<plugin>/<name>\`
11
+ 3. Project > user; non-marketplace plugins > marketplace.
12
+
13
+ Ambiguous names exit \`4\` — disambiguate with \`<plugin>:<name>\` or \`_:<name>\`.
8
14
 
9
15
  ## Discover
10
16
 
11
17
  \`\`\`
12
- crtr skill list # one per line: <scope>:<plugin>/<name> — <description>
13
- crtr skill search <query> # rank by name, description, keywords
14
- crtr skill grep <pattern> # regex search across SKILL.md bodies
18
+ crtr skill list # <qualifier> — <description>
19
+ crtr skill search <query> # ranked by name/description/keywords
20
+ crtr skill grep <pattern> # regex across SKILL.md bodies
15
21
  \`\`\`
16
22
 
17
23
  ## Load
18
24
 
19
25
  \`\`\`
20
- crtr skill show <name> # print SKILL.md body to stdout
21
- crtr skill show <plugin>:<name> # disambiguate when names collide
22
- crtr skill path <name> # absolute path to SKILL.md
23
- crtr skill where <name> # {scope, plugin, path} as JSON
26
+ crtr skill show <name> # body to stdout (default verb)
27
+ crtr skill show _:<name> # explicit scope-direct
28
+ crtr skill path <name> # absolute path
29
+ crtr skill where <name> # {scope, plugin, path} JSON
24
30
  \`\`\`
25
31
 
26
- \`show\` is the default verb: \`crtr skill <name>\` (with no verb) also prints
27
- the body.
28
-
29
- ## Author
32
+ ## Author (progressive disclosure)
30
33
 
31
34
  \`\`\`
32
- crtr skill new <plugin>:<name> --description "..." # scaffold a new skill
33
- crtr skill show authoring-skills # the SKILL.md authoring guide
35
+ crtr skill create [topic...] # pick a template type
36
+ crtr skill template <type> [topic] # workflow + skeleton for that type
37
+ crtr skill new <name> # bare scaffold, scope-direct
34
38
  \`\`\`
35
39
 
40
+ Don't load \`create\` and \`template\` in the same turn — \`create\` decides the
41
+ type, then call \`template\`.
42
+
36
43
  ## Toggle
37
44
 
38
45
  \`\`\`
39
- crtr skill enable <name> # clear any disable in the chosen scope
40
- crtr skill disable <name> # hide from list and agent discovery
46
+ crtr skill enable <name>
47
+ crtr skill disable <name>
41
48
  \`\`\`
42
49
 
43
50
  ## Exit codes
44
51
 
45
- - \`0\` success
46
- - \`3\` — skill not found
47
- - \`4\` — ambiguous name; use \`<plugin>:<name>\`
52
+ \`0\` success · \`3\` not found · \`4\` ambiguous (qualify name)
53
+ `;
54
+ }
55
+ export function skillCreatePrompt(topic) {
56
+ const topicLine = topic
57
+ ? `Topic: **${topic}**`
58
+ : `No topic provided — ask the user what to capture before proceeding.`;
59
+ return `# Author a skill — step 1: pick template type
60
+
61
+ You are about to write a skill (markdown read by future LLM agent sessions,
62
+ not humans). Pick the template, then load its workflow.
63
+
64
+ ${topicLine}
65
+
66
+ ## Templates
67
+
68
+ - \`primer\` — codebase/architectural knowledge ("how does X work, why, what
69
+ are the gotchas"). Triggers parallel-explore research.
70
+ - \`playbook\` — methodology/judgment ("how to think about X"). The
71
+ \`authoring:skills\`-style skill that teaches decisions, not facts.
72
+ - \`freeform\` — anything else (glossary, decision record, runbook, prefs).
73
+
74
+ ## Next
75
+
76
+ 1. Pick a type. If unclear, use \`AskUserQuestion\` with your best guess first.
77
+ 2. Run:
78
+
79
+ \`\`\`
80
+ crtr skill template <type>${topic ? ` ${topic}` : ' [topic]'}
81
+ \`\`\`
82
+
83
+ That output contains the research methodology, SKILL.md skeleton, and
84
+ scaffold command. Follow it directly — don't paraphrase.
85
+
86
+ ## Push back when
87
+
88
+ - Subsystem is small/self-evident → suggest CLAUDE.md note instead of primer.
89
+ - "Topic" is really a one-off task → don't capture; just do the work.
90
+ `;
91
+ }
92
+ export function skillTemplatePrompt(type, topic) {
93
+ const t = type.toLowerCase();
94
+ if (t === 'primer')
95
+ return primerTemplatePrompt(topic);
96
+ if (t === 'playbook')
97
+ return playbookTemplatePrompt(topic);
98
+ if (t === 'freeform')
99
+ return freeformTemplatePrompt(topic);
100
+ return `unknown template type: ${type}\nvalid: primer | playbook | freeform\nrun \`crtr skill create\` to pick.\n`;
101
+ }
102
+ function topicLine(topic) {
103
+ return topic
104
+ ? `Topic: **${topic}**`
105
+ : `No topic — confirm with the user before continuing.`;
106
+ }
107
+ function primerTemplatePrompt(topic) {
108
+ return `# Primer — codebase knowledge skill
109
+
110
+ **Audience: future LLM agent sessions.** Captures *why* a subsystem exists +
111
+ non-obvious facts that code alone doesn't reveal. Lets a future session skip
112
+ re-exploration.
113
+
114
+ ${topicLine(topic)}
115
+
116
+ ## 1. Inventory (parallel)
117
+
118
+ - \`ls\` repo top level
119
+ - check stack manifests
120
+ - \`git log --oneline -15\` in this area
121
+ - \`crtr skill search <topic>\` / \`crtr skill list\` — does a primer already exist?
122
+
123
+ If subsystem is small/self-evident, **stop**. Suggest a CLAUDE.md note. Primers
124
+ are for large, complicated, or unintuitive systems only.
125
+
126
+ ## 2. Scope + name
127
+
128
+ - **Scope**: \`project\` by default. \`user\` only if cross-repo.
129
+ - **Name**: kebab-case. Confirm no collision: \`crtr skill where <name>\`.
130
+
131
+ ## 3. Parallel exploration
132
+
133
+ Dispatch **4–8 \`Explore\` subagents in parallel**, partitioned by *slice* (not
134
+ directory):
135
+
136
+ - Entry points (routes, CLI, events, public exports)
137
+ - Data model (schemas, types, invariants)
138
+ - Control flow (typical request/job end-to-end)
139
+ - External integrations (APIs, queues, env vars)
140
+ - Tests (what's tested = what's load-bearing)
141
+ - History (recent git log surfaces pain points)
142
+ - Cross-cutting (auth, errors, logging, flags as they apply)
143
+
144
+ Each subagent returns: concrete \`file:line\` refs, *non-obvious* facts (skip
145
+ filename-obvious), naming conventions, gotchas. Reject vague summaries.
146
+
147
+ ## 4. Verify with user
148
+
149
+ Code = *what*. User = *why*. Use \`AskUserQuestion\` (≤4 questions,
150
+ multi-choice, best-guess first):
151
+
152
+ - Business purpose / who depends on it
153
+ - Surprising-looking architectural decisions
154
+ - Ownership / deprecation status / expected scale
155
+ - Canonical flow when multiple exist
156
+
157
+ Skip if greppable or won't change the primer. **Never write unconfirmed
158
+ assumptions.**
159
+
160
+ ## 5. Scaffold
161
+
162
+ \`\`\`
163
+ crtr skill new <name> --scope project --description "<what+when, ≤250 chars, front-loaded triggers>"
164
+ \`\`\`
165
+
166
+ ## 6. Write the body
167
+
168
+ \`\`\`markdown
169
+ # <topic>
170
+
171
+ ## Purpose
172
+ Why this exists. Problem solved. Who depends on it.
173
+ (1–3 tight paragraphs — what code can't tell you.)
174
+
175
+ ## Architecture
176
+ Components, responsibilities, data/control flow, boundaries.
177
+
178
+ ## File map
179
+ | Path | Role |
180
+ |------|------|
181
+ | \`src/foo/bar.ts\` | … |
182
+
183
+ ## Key concepts
184
+ Domain terms, invariants, non-obvious constraints.
185
+
186
+ ## Entry points
187
+ \`file:line\` where work enters.
188
+
189
+ ## Gotchas
190
+ Non-obvious coupling. Looks-broken-but-isn't. Past footguns.
191
+
192
+ ## Related
193
+ - \`<other-skill>\` — interaction
194
+ \`\`\`
195
+
196
+ **Density rules:**
197
+ - \`file:line\` over prose
198
+ - Tables where structure fits
199
+ - Skip 30-second-skim-obvious
200
+ - No "this section covers…" meta
201
+ - Budget ~150 lines; deeper reference → sibling files
202
+
203
+ ## 7. Verify
204
+
205
+ \`\`\`
206
+ crtr skill where <name>
207
+ crtr skill show <name>
208
+ crtr skill search <keyword> # confirm description triggers discovery
209
+ \`\`\`
210
+
211
+ Sharpen description if discovery misses. Cut body if bloated.
212
+
213
+ ## Updates
214
+
215
+ If updating existing primer: diff draft vs current, call out changes + why
216
+ before writing. Update related skills' \`## Related\` sections.
217
+ `;
218
+ }
219
+ function playbookTemplatePrompt(topic) {
220
+ return `# Playbook — methodology skill
221
+
222
+ **Audience: future LLM agent sessions.** Teaches *judgment*, not facts —
223
+ decision frameworks, heuristics, when-to-use / when-not-to-use. Examples:
224
+ skill-authoring, debugging methodology, multi-agent orchestration.
225
+
226
+ ${topicLine(topic)}
227
+
228
+ ## Litmus test
229
+
230
+ > Does this teach judgment, or describe an API?
231
+
232
+ If you'd write *"when X, do Y because Z"* → playbook. If you'd write tables
233
+ of fields/flags/events → reference material (put in sibling \`reference.md\`,
234
+ not SKILL.md). If neither fits → use \`crtr skill template freeform\` instead.
235
+
236
+ **Playbook markers:** teaches a framework · has "when (not) to use" · prose
237
+ over tables · reader makes better decisions after 30 seconds.
238
+
239
+ ## 1. Interview
240
+
241
+ A playbook = user's accumulated judgment. Not greppable. Use
242
+ \`AskUserQuestion\` (≤4, multi-choice, best-guess first):
243
+
244
+ - The decision this skill teaches
245
+ - 2–4 most common failure modes without it
246
+ - Triggers (words/situations that should load it)
247
+ - Non-obvious rules that surprise newcomers
248
+
249
+ Push back on vagueness. *"Be thoughtful"* ≠ heuristic. *"Prefer one bundled
250
+ PR over many small ones for refactors here, because review churn dominates"*
251
+ = heuristic.
252
+
253
+ ## 2. Scope + name
254
+
255
+ - **Scope**: \`user\` for cross-project methodology. \`project\` for repo-specific.
256
+ - **Name**: kebab-case, verb-or-noun-phrase. Not "guide-to-X".
257
+ - Check \`crtr skill where <name>\`.
258
+
259
+ ## 3. Scaffold
260
+
261
+ \`\`\`
262
+ crtr skill new <name> --scope <user|project> --description "<what it teaches + when to load, ≤250 chars, front-loaded triggers>"
263
+ \`\`\`
264
+
265
+ ## 4. Density rules
266
+
267
+ LLM reasoning degrades past ~3k tokens. **Budget ~150 lines for SKILL.md.**
268
+
269
+ - Decision-first. *"When you need X"* before *"how X works"*.
270
+ - One well-placed "don't" > three paragraphs of explanation.
271
+ - Reasoning chains > example outputs. Show *how to think*, not *what to produce*.
272
+ - Section >20 lines without teaching judgment → move to \`reference.md\`.
273
+
274
+ **Test:** can someone reading 30 seconds make a better decision? If they need
275
+ to read the whole thing for value, you've buried the judgment.
276
+
277
+ ## 5. Body skeleton
278
+
279
+ \`\`\`markdown
280
+ # <skill name>
281
+
282
+ <1-paragraph: what + when to load>
283
+
284
+ ## When to use
285
+ - <trigger>
286
+
287
+ ## When NOT to use
288
+ - <anti-trigger>
289
+
290
+ ## The core decision
291
+ <central judgment — usually a heuristic or framework>
292
+
293
+ ## <heuristic 1>
294
+ <2–6 lines, brief (anti-)example>
295
+
296
+ ## <heuristic 2>
297
+
298
+
299
+ ## Failure modes
300
+ - **<name>**: what it looks like; how to avoid
301
+
302
+ ## Related
303
+ - \`<other-skill>\` — interaction
304
+ \`\`\`
305
+
306
+ ## 6. Progressive disclosure
307
+
308
+ If deep reference is needed:
309
+
310
+ \`\`\`
311
+ <skill-dir>/
312
+ SKILL.md # judgment layer — <150 lines
313
+ reference.md # lookup layer
314
+ examples.md # optional worked examples
315
+ \`\`\`
316
+
317
+ SKILL.md *links* to siblings (\`see [reference.md](reference.md)\`). Agent
318
+ loads supporting files only when needed.
319
+
320
+ ## 7. Verify
321
+
322
+ \`\`\`
323
+ crtr skill where <name>
324
+ crtr skill show <name>
325
+ crtr skill search <keyword>
326
+ \`\`\`
327
+
328
+ ## Deep-dive reference
329
+
330
+ For canonical SKILL.md authoring (frontmatter fields, argument passing,
331
+ dynamic context, subagent forking, hooks):
332
+
333
+ \`\`\`
334
+ crtr skill show authoring-skills
335
+ \`\`\`
336
+
337
+ The playbook above gives you structure + density rules. \`authoring-skills\`
338
+ covers the SKILL.md surface itself.
339
+
340
+ ## Constraints
341
+
342
+ - Topic fails litmus? → \`crtr skill template freeform\` or \`primer\`.
343
+ - No unconfirmed heuristics — if not from user experience or clear principle,
344
+ leave it out.
345
+ - Update related skills' \`## Related\` if interactions exist.
346
+ `;
347
+ }
348
+ function freeformTemplatePrompt(topic) {
349
+ return `# Freeform — escape hatch skill
350
+
351
+ **Audience: future LLM agent sessions.** Use when content doesn't fit
352
+ \`primer\` (codebase knowledge) or \`playbook\` (methodology) — glossaries,
353
+ decisions, runbooks, lists, preferences.
354
+
355
+ ${topicLine(topic)}
356
+
357
+ ## 1. Pick a shape
358
+
359
+ What kind of thing is this?
360
+
361
+ - Terms + definitions → glossary-shaped
362
+ - "We decided X, here's why" → decision-shaped
363
+ - Procedure with steps + rollback → runbook-shaped
364
+ - User preferences → preference-shaped
365
+ - None of the above → freeform
366
+
367
+ No strict template; the shape just tells you what to ask for.
368
+
369
+ ## 2. Interview
370
+
371
+ \`AskUserQuestion\` (≤4, multi-choice, best-guess first). Get only what you
372
+ need to write the skill. **No unconfirmed assumptions** — if not from user
373
+ or grep, omit it.
374
+
375
+ ## 3. Scope + name + scaffold
376
+
377
+ \`\`\`
378
+ crtr skill new <name> --scope <user|project> --description "<what+when, ≤250 chars, front-loaded triggers>"
379
+ \`\`\`
380
+
381
+ ## 4. Body — pick the closest skeleton
382
+
383
+ **Glossary:**
384
+ \`\`\`markdown
385
+ # <domain> glossary
386
+ | Term | Definition | Notes |
387
+ |------|------------|-------|
388
+ \`\`\`
389
+
390
+ **Decision:**
391
+ \`\`\`markdown
392
+ # <decision> — <date>
393
+ ## Context
394
+ ## Decision
395
+ ## Consequences
396
+ ## Alternatives considered
397
+ \`\`\`
398
+
399
+ **Runbook:**
400
+ \`\`\`markdown
401
+ # <procedure>
402
+ ## When to run
403
+ ## Steps
404
+ ## Verification
405
+ ## Rollback
406
+ \`\`\`
407
+
408
+ **Preference:**
409
+ \`\`\`markdown
410
+ # <preference>
411
+ ## Rule
412
+ ## Why
413
+ ## How to apply
414
+ \`\`\`
415
+
416
+ Or invent your own. Stay tight — no padding.
417
+
418
+ ## 5. Verify
419
+
420
+ \`\`\`
421
+ crtr skill where <name>
422
+ crtr skill show <name>
423
+ crtr skill search <keyword>
424
+ \`\`\`
425
+
426
+ ## Switch templates if needed
427
+
428
+ If the content is actually methodology or codebase knowledge:
429
+
430
+ \`\`\`
431
+ crtr skill template playbook ${topic ? topic : '<topic>'}
432
+ crtr skill template primer ${topic ? topic : '<topic>'}
433
+ \`\`\`
48
434
  `;
49
435
  }
@@ -98,10 +98,35 @@ EOF
98
98
  - If you are running inside tmux, the saved spec auto-opens in a side pane
99
99
  via termrender. No extra step needed.
100
100
 
101
- ## Phase 5: Done
101
+ ## Phase 5: Review
102
102
 
103
- Your turn ends after the save command succeeds. No need to summarize the spec
104
- in chat the user can read the file.
103
+ By default the save command **blocks** while a reviewer agent reads the spec
104
+ in a side pane (10-min budget) and returns its findings on stdout under a
105
+ \`--- review ---\` marker. **Read the review** when the command returns:
106
+
107
+ - If \`Status: Approved\`, you are done.
108
+ - If \`Status: Issues Found\`, address the listed issues by editing the spec
109
+ (\`crtr spec edit <name>\` or rewriting via the save command), then save
110
+ again to re-trigger review.
111
+
112
+ Pass \`--no-review\` only when the spec is genuinely trivial (a paragraph, one
113
+ behavior, no design decisions). For anything substantive, take the review.
114
+
115
+ ## Phase 6: Done
116
+
117
+ After the review returns Approved (or you have addressed its issues), your
118
+ turn ends. No need to summarize the spec in chat — the user can read the file.
119
+
120
+ If the user is ready to move into planning, ask once whether they want to
121
+ hand off now. If yes, run:
122
+
123
+ \`\`\`bash
124
+ crtr agent plan --spec <name>
125
+ \`\`\`
126
+
127
+ This fires up a planner in a new tmux pane and closes the current pane a
128
+ few seconds later. Do NOT run this without the user's go-ahead — the kill
129
+ is irreversible for this session.
105
130
 
106
131
  ## See also
107
132
 
package/dist/types.d.ts CHANGED
@@ -59,6 +59,7 @@ export interface ScopeConfig {
59
59
  plugins: Record<string, ConfigPluginEntry>;
60
60
  skills: Record<string, ConfigSkillEntry>;
61
61
  auto_update: AutoUpdateConfig;
62
+ max_panes_per_window: number;
62
63
  }
63
64
  export interface ScopeState {
64
65
  marketplaces: Record<string, {
@@ -111,6 +112,8 @@ export declare const CONFIG_FILE = "config.json";
111
112
  export declare const STATE_FILE = "state.json";
112
113
  export declare const SKILL_ENTRY_FILE = "SKILL.md";
113
114
  export declare const SKILLS_DIR = "skills";
115
+ export declare const SCOPE_SKILL_PLUGIN = "_";
116
+ export declare const DEFAULT_MAX_PANES_PER_WINDOW = 3;
114
117
  export declare function defaultScopeConfig(): ScopeConfig;
115
118
  export declare function skillConfigKey(plugin: string, name: string): string;
116
119
  export declare function defaultScopeState(): ScopeState;
package/dist/types.js CHANGED
@@ -16,6 +16,11 @@ export const CONFIG_FILE = 'config.json';
16
16
  export const STATE_FILE = 'state.json';
17
17
  export const SKILL_ENTRY_FILE = 'SKILL.md';
18
18
  export const SKILLS_DIR = 'skills';
19
+ // Sentinel plugin name for skills that live at a scope root (no plugin wrapper).
20
+ // Stored as `<scope-root>/skills/<name>/SKILL.md`. Shown in listings without the
21
+ // `_/` prefix.
22
+ export const SCOPE_SKILL_PLUGIN = '_';
23
+ export const DEFAULT_MAX_PANES_PER_WINDOW = 3;
19
24
  export function defaultScopeConfig() {
20
25
  return {
21
26
  schema_version: SCHEMA_VERSION,
@@ -23,6 +28,7 @@ export function defaultScopeConfig() {
23
28
  plugins: {},
24
29
  skills: {},
25
30
  auto_update: { crtr: 'notify', content: 'notify', interval_hours: 24 },
31
+ max_panes_per_window: DEFAULT_MAX_PANES_PER_WINDOW,
26
32
  };
27
33
  }
28
34
  export function skillConfigKey(plugin, name) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@crouton-kit/crouter",
3
- "version": "0.1.4",
3
+ "version": "0.1.7",
4
4
  "description": "crtr — fast access to skills, plugins, and marketplaces",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",