@thomas-powers-jr/cadence-host-toolkit 1.54.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Thomas Powers
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.
@@ -0,0 +1,37 @@
1
+ export interface ManagedHookEntry {
2
+ matcher?: string;
3
+ hooks: Array<{
4
+ type: 'command';
5
+ command: string;
6
+ }>;
7
+ _managedBy?: string;
8
+ }
9
+ /**
10
+ * True when a hook entry carries CADENCE's own managed marker
11
+ * (`_managedBy: 'cadence'`). This is the JSON-hook-entry analog of the
12
+ * `<!-- managed-by: cadence -->` marker used for the rendered slash-command
13
+ * files (`install-commands.ts`, out of scope here) — the shared convention
14
+ * both host adapters use to tell "cadence installed and owns this" apart
15
+ * from "the user (or a third-party tool) put this here, leave it alone."
16
+ */
17
+ export declare function isCadenceManagedEntry(entry: ManagedHookEntry): boolean;
18
+ /**
19
+ * Merge `desired` cadence-managed hook entries into an `existing`
20
+ * hooks-by-event map.
21
+ *
22
+ * For every event key present in `desired`: entries considered "stale" (by
23
+ * default, any entry already carrying the cadence managed-marker from a
24
+ * prior install — see {@link isCadenceManagedEntry}) are evicted, and the
25
+ * fresh `desired` entries for that event are appended. Anything else on that
26
+ * event — a user-authored or third-party hook — is preserved untouched.
27
+ * Event keys present only in `existing` (not part of this install) are left
28
+ * exactly as they were.
29
+ *
30
+ * `isStale` is overridable so an adapter can additionally evict its own
31
+ * legacy markers alongside the current cadence one (e.g. host-claude-code's
32
+ * pre-rename `_managedBy: 'keel'` entries — Phase 18.1's F2 rename rollout).
33
+ *
34
+ * Pure: does not mutate `existing` or `desired`; returns a new map.
35
+ */
36
+ export declare function mergeManagedHookEntries(existing: Record<string, ManagedHookEntry[]>, desired: Record<string, ManagedHookEntry[]>, isStale?: (entry: ManagedHookEntry) => boolean): Record<string, ManagedHookEntry[]>;
37
+ //# sourceMappingURL=install-merge.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-merge.d.ts","sourceRoot":"","sources":["../src/install-merge.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,gBAAgB;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,SAAS,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACnD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,OAAO,CAEtE;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,EAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,EAC3C,OAAO,GAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,OAA+B,GACpE,MAAM,CAAC,MAAM,EAAE,gBAAgB,EAAE,CAAC,CAOpC"}
@@ -0,0 +1,38 @@
1
+ /**
2
+ * True when a hook entry carries CADENCE's own managed marker
3
+ * (`_managedBy: 'cadence'`). This is the JSON-hook-entry analog of the
4
+ * `<!-- managed-by: cadence -->` marker used for the rendered slash-command
5
+ * files (`install-commands.ts`, out of scope here) — the shared convention
6
+ * both host adapters use to tell "cadence installed and owns this" apart
7
+ * from "the user (or a third-party tool) put this here, leave it alone."
8
+ */
9
+ export function isCadenceManagedEntry(entry) {
10
+ return entry._managedBy === 'cadence';
11
+ }
12
+ /**
13
+ * Merge `desired` cadence-managed hook entries into an `existing`
14
+ * hooks-by-event map.
15
+ *
16
+ * For every event key present in `desired`: entries considered "stale" (by
17
+ * default, any entry already carrying the cadence managed-marker from a
18
+ * prior install — see {@link isCadenceManagedEntry}) are evicted, and the
19
+ * fresh `desired` entries for that event are appended. Anything else on that
20
+ * event — a user-authored or third-party hook — is preserved untouched.
21
+ * Event keys present only in `existing` (not part of this install) are left
22
+ * exactly as they were.
23
+ *
24
+ * `isStale` is overridable so an adapter can additionally evict its own
25
+ * legacy markers alongside the current cadence one (e.g. host-claude-code's
26
+ * pre-rename `_managedBy: 'keel'` entries — Phase 18.1's F2 rename rollout).
27
+ *
28
+ * Pure: does not mutate `existing` or `desired`; returns a new map.
29
+ */
30
+ export function mergeManagedHookEntries(existing, desired, isStale = isCadenceManagedEntry) {
31
+ const merged = { ...existing };
32
+ for (const [event, entries] of Object.entries(desired)) {
33
+ const kept = (merged[event] ?? []).filter((entry) => !isStale(entry));
34
+ merged[event] = [...kept, ...entries];
35
+ }
36
+ return merged;
37
+ }
38
+ //# sourceMappingURL=install-merge.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"install-merge.js","sourceRoot":"","sources":["../src/install-merge.ts"],"names":[],"mappings":"AAMA;;;;;;;GAOG;AACH,MAAM,UAAU,qBAAqB,CAAC,KAAuB;IAC3D,OAAO,KAAK,CAAC,UAAU,KAAK,SAAS,CAAC;AACxC,CAAC;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,UAAU,uBAAuB,CACrC,QAA4C,EAC5C,OAA2C,EAC3C,UAAgD,qBAAqB;IAErE,MAAM,MAAM,GAAuC,EAAE,GAAG,QAAQ,EAAE,CAAC;IACnE,KAAK,MAAM,CAAC,KAAK,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACvD,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC;QACtE,MAAM,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,23 @@
1
+ export interface LocalPaths {
2
+ /** Absolute path to a host adapter's compiled CLI entry (dist/cli.js). */
3
+ shimCli: string;
4
+ /** Absolute path to the workspace @thomas-powers-jr/cadence-core CLI entry (dist/cli/index.js). */
5
+ coreCli: string;
6
+ }
7
+ /**
8
+ * Resolves absolute paths to the local (workspace) builds of a host adapter
9
+ * and `@thomas-powers-jr/cadence-core`, given the URL of a module living at that
10
+ * adapter's own package root (i.e. `packages/<adapter>/src/locate-self.ts` or
11
+ * `packages/<adapter>/dist/locate-self.js`). Designed to work both at runtime
12
+ * (compiled, running from `dist/`) and under vitest (running from `src/`).
13
+ *
14
+ * Shared by every host adapter (phase 222 — formerly duplicated verbatim in
15
+ * `host-claude-code/src/locate-self.ts` and `host-codex/src/locate-self.ts`).
16
+ * This works across adapters because every adapter package lives at the same
17
+ * depth under `packages/`, so the relative hop up to
18
+ * `packages/core/dist/cli/index.js` is identical regardless of which adapter
19
+ * is asking — the caller only needs to supply *its own* `import.meta.url` so
20
+ * the function anchors to the right adapter directory.
21
+ */
22
+ export declare function resolveAdapterLocalPaths(adapterModuleUrl: string): LocalPaths;
23
+ //# sourceMappingURL=locate-self.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate-self.d.ts","sourceRoot":"","sources":["../src/locate-self.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,UAAU;IACzB,0EAA0E;IAC1E,OAAO,EAAE,MAAM,CAAC;IAChB,mGAAmG;IACnG,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,wBAAwB,CAAC,gBAAgB,EAAE,MAAM,GAAG,UAAU,CAQ7E"}
@@ -0,0 +1,27 @@
1
+ import { basename, dirname, resolve } from 'node:path';
2
+ import { fileURLToPath } from 'node:url';
3
+ /**
4
+ * Resolves absolute paths to the local (workspace) builds of a host adapter
5
+ * and `@thomas-powers-jr/cadence-core`, given the URL of a module living at that
6
+ * adapter's own package root (i.e. `packages/<adapter>/src/locate-self.ts` or
7
+ * `packages/<adapter>/dist/locate-self.js`). Designed to work both at runtime
8
+ * (compiled, running from `dist/`) and under vitest (running from `src/`).
9
+ *
10
+ * Shared by every host adapter (phase 222 — formerly duplicated verbatim in
11
+ * `host-claude-code/src/locate-self.ts` and `host-codex/src/locate-self.ts`).
12
+ * This works across adapters because every adapter package lives at the same
13
+ * depth under `packages/`, so the relative hop up to
14
+ * `packages/core/dist/cli/index.js` is identical regardless of which adapter
15
+ * is asking — the caller only needs to supply *its own* `import.meta.url` so
16
+ * the function anchors to the right adapter directory.
17
+ */
18
+ export function resolveAdapterLocalPaths(adapterModuleUrl) {
19
+ const here = dirname(fileURLToPath(adapterModuleUrl));
20
+ const distDir = basename(here) === 'src' ? resolve(here, '..', 'dist') : here;
21
+ const adapterRoot = resolve(distDir, '..');
22
+ return {
23
+ shimCli: resolve(distDir, 'cli.js'),
24
+ coreCli: resolve(adapterRoot, '..', 'core', 'dist', 'cli', 'index.js'),
25
+ };
26
+ }
27
+ //# sourceMappingURL=locate-self.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"locate-self.js","sourceRoot":"","sources":["../src/locate-self.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AASzC;;;;;;;;;;;;;;GAcG;AACH,MAAM,UAAU,wBAAwB,CAAC,gBAAwB;IAC/D,MAAM,IAAI,GAAG,OAAO,CAAC,aAAa,CAAC,gBAAgB,CAAC,CAAC,CAAC;IACtD,MAAM,OAAO,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC9E,MAAM,WAAW,GAAG,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAC3C,OAAO;QACL,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,QAAQ,CAAC;QACnC,OAAO,EAAE,OAAO,CAAC,WAAW,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,CAAC;KACvE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,43 @@
1
+ import type { AbstractEvent, ExtractedPayload } from '@thomas-powers-jr/cadence-types';
2
+ export type { ExtractedPayload };
3
+ export declare const EDIT_TOOL_MATCHER = "Edit|Write|MultiEdit|NotebookEdit";
4
+ export declare const SKILL_TOOL_MATCHER = "Skill";
5
+ /**
6
+ * Map a host hook event name to its cadence abstract event. `toolName`
7
+ * disambiguates `PostToolUse` between the edit-tool flow (post-tool-edit)
8
+ * and the Skill-tool flow (skill-invoke, Phase 23.4).
9
+ */
10
+ export declare function mapEvent(hostEvent: string, toolName?: string): AbstractEvent | null;
11
+ export declare function extractPayload(raw: unknown): ExtractedPayload | undefined;
12
+ export interface RouteResult {
13
+ abstractEvent: AbstractEvent | null;
14
+ translatedStdin: string;
15
+ }
16
+ /**
17
+ * Translate one host stdin-JSON hook event into a cadence abstract event plus
18
+ * the stdin the core dispatcher should receive. The 8-step algorithm: parse
19
+ * JSON (1), reject non-object/array payloads (2), require a string
20
+ * `hook_event_name` (3), read `tool_name` (4), map the event — with the Skill
21
+ * disambiguation (5), bail out on an unmapped event (6), defensively re-filter
22
+ * Pre/PostToolUse to known edit tools (7), then extract + translate the
23
+ * payload (8). Unmapped events, malformed JSON, and Pre/PostToolUse for
24
+ * non-edit tools return `{ abstractEvent: null }` with the raw stdin passed
25
+ * through untouched (the core never sees them).
26
+ */
27
+ export declare function routeHookEvent(raw: string): RouteResult;
28
+ export interface CommandSpec {
29
+ name: string;
30
+ description: string;
31
+ argumentHint?: string;
32
+ cli: string;
33
+ trailing?: string;
34
+ /**
35
+ * Multi-line prompt body rendered after the auto-run command line. Used by
36
+ * dialogue commands (e.g. cadence-scout, cadence-dispatch) that are a
37
+ * prompt template rather than a thin CLI shell-out. Thin commands leave
38
+ * this unset.
39
+ */
40
+ body?: string;
41
+ }
42
+ export declare const COMMANDS: CommandSpec[];
43
+ //# sourceMappingURL=routing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.d.ts","sourceRoot":"","sources":["../src/routing.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,iCAAiC,CAAC;AAKvF,YAAY,EAAE,gBAAgB,EAAE,CAAC;AASjC,eAAO,MAAM,iBAAiB,sCAAsC,CAAC;AACrE,eAAO,MAAM,kBAAkB,UAAU,CAAC;AAY1C;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,aAAa,GAAG,IAAI,CAGnF;AAID,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,gBAAgB,GAAG,SAAS,CAqCzE;AAED,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,aAAa,GAAG,IAAI,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,WAAW,CAwCvD;AAaD,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAQD,eAAO,MAAM,QAAQ,EAAE,WAAW,EAsGjC,CAAC"}
@@ -0,0 +1,226 @@
1
+ import { COMMAND_GUIDANCE, DISPATCH_DIALOGUE, SCOUT_DIALOGUE } from '@thomas-powers-jr/cadence-types';
2
+ // ---------------------------------------------------------------------------
3
+ // Hook-event routing (formerly duplicated in each adapter's event-map.ts /
4
+ // shim.ts). Both host-claude-code and host-codex receive Claude-Code-shaped
5
+ // hook JSON on stdin and translate it into a cadence AbstractEvent — this is
6
+ // the one shared implementation of that 8-step dispatch algorithm.
7
+ // ---------------------------------------------------------------------------
8
+ export const EDIT_TOOL_MATCHER = 'Edit|Write|MultiEdit|NotebookEdit';
9
+ export const SKILL_TOOL_MATCHER = 'Skill';
10
+ const EVENT_TABLE = {
11
+ SessionStart: 'session-start',
12
+ UserPromptSubmit: 'user-prompt',
13
+ PreToolUse: 'pre-tool-edit',
14
+ PostToolUse: 'post-tool-edit',
15
+ Stop: 'session-stop',
16
+ SubagentStop: 'subagent-result',
17
+ SubagentStart: 'subagent-start',
18
+ };
19
+ /**
20
+ * Map a host hook event name to its cadence abstract event. `toolName`
21
+ * disambiguates `PostToolUse` between the edit-tool flow (post-tool-edit)
22
+ * and the Skill-tool flow (skill-invoke, Phase 23.4).
23
+ */
24
+ export function mapEvent(hostEvent, toolName) {
25
+ if (hostEvent === 'PostToolUse' && toolName === 'Skill')
26
+ return 'skill-invoke';
27
+ return EVENT_TABLE[hostEvent] ?? null;
28
+ }
29
+ const EDIT_TOOLS = new Set(['Edit', 'Write', 'MultiEdit', 'NotebookEdit']);
30
+ export function extractPayload(raw) {
31
+ if (!raw || typeof raw !== 'object')
32
+ return undefined;
33
+ const r = raw;
34
+ const agentId = typeof r.agent_id === 'string' && r.agent_id.length > 0 ? r.agent_id : undefined;
35
+ const agentType = typeof r.agent_type === 'string' && r.agent_type.length > 0 ? r.agent_type : undefined;
36
+ const agentFields = { ...(agentId ? { agentId } : {}), ...(agentType ? { agentType } : {}) };
37
+ if (r.hook_event_name !== 'PreToolUse' && r.hook_event_name !== 'PostToolUse') {
38
+ // SubagentStart/SubagentStop (and any other future event) only ever
39
+ // carry agent fields — no files/skill to extract.
40
+ return Object.keys(agentFields).length > 0 ? agentFields : undefined;
41
+ }
42
+ if (!r.tool_name)
43
+ return Object.keys(agentFields).length > 0 ? agentFields : undefined;
44
+ // Skill tool: extract skill name (Phase 23.4).
45
+ if (r.tool_name === 'Skill') {
46
+ const s = r.tool_input?.skill;
47
+ if (typeof s !== 'string' || s.length === 0) {
48
+ return Object.keys(agentFields).length > 0 ? agentFields : undefined;
49
+ }
50
+ return { skill: s, ...agentFields };
51
+ }
52
+ // Edit tools: extract file path.
53
+ if (!EDIT_TOOLS.has(r.tool_name)) {
54
+ return Object.keys(agentFields).length > 0 ? agentFields : undefined;
55
+ }
56
+ const fp = r.tool_input?.file_path;
57
+ if (typeof fp !== 'string' || fp.length === 0) {
58
+ return Object.keys(agentFields).length > 0 ? agentFields : undefined;
59
+ }
60
+ return { files: [fp], ...agentFields };
61
+ }
62
+ /**
63
+ * Translate one host stdin-JSON hook event into a cadence abstract event plus
64
+ * the stdin the core dispatcher should receive. The 8-step algorithm: parse
65
+ * JSON (1), reject non-object/array payloads (2), require a string
66
+ * `hook_event_name` (3), read `tool_name` (4), map the event — with the Skill
67
+ * disambiguation (5), bail out on an unmapped event (6), defensively re-filter
68
+ * Pre/PostToolUse to known edit tools (7), then extract + translate the
69
+ * payload (8). Unmapped events, malformed JSON, and Pre/PostToolUse for
70
+ * non-edit tools return `{ abstractEvent: null }` with the raw stdin passed
71
+ * through untouched (the core never sees them).
72
+ */
73
+ export function routeHookEvent(raw) {
74
+ let parsed;
75
+ try {
76
+ parsed = JSON.parse(raw); // 1. parse
77
+ }
78
+ catch {
79
+ return { abstractEvent: null, translatedStdin: raw };
80
+ }
81
+ if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
82
+ // 2. reject non-object/array payloads
83
+ return { abstractEvent: null, translatedStdin: raw };
84
+ }
85
+ const obj = parsed;
86
+ if (typeof obj.hook_event_name !== 'string') {
87
+ // 3. require a string hook_event_name
88
+ return { abstractEvent: null, translatedStdin: raw };
89
+ }
90
+ // 4. read tool_name
91
+ const toolName = parsed.tool_name;
92
+ const toolNameStr = typeof toolName === 'string' ? toolName : undefined;
93
+ // 5. map the event (Skill disambiguation happens inside mapEvent)
94
+ const abstractEvent = mapEvent(obj.hook_event_name, toolNameStr);
95
+ if (abstractEvent === null) {
96
+ // 6. bail out on an unmapped event
97
+ return { abstractEvent: null, translatedStdin: raw };
98
+ }
99
+ // 7. Defensive filter: PreToolUse/PostToolUse for non-edit tools should be
100
+ // dropped even though the host's own hook matcher already restricts them.
101
+ // Skill tool takes its own route (skill-invoke) above and bypasses this
102
+ // filter.
103
+ if (abstractEvent === 'pre-tool-edit' || abstractEvent === 'post-tool-edit') {
104
+ if (typeof toolName !== 'string' || !EDIT_TOOLS.has(toolName)) {
105
+ return { abstractEvent: null, translatedStdin: raw };
106
+ }
107
+ }
108
+ // 8. extract + translate the payload
109
+ const extracted = extractPayload(parsed);
110
+ const translated = { ...parsed };
111
+ if (extracted?.files)
112
+ translated.files = extracted.files;
113
+ if (extracted?.skill)
114
+ translated.skill = extracted.skill;
115
+ return { abstractEvent, translatedStdin: JSON.stringify(translated) };
116
+ }
117
+ // Guidance prose (description/trailing) + the dialogue bodies live in the
118
+ // shared `@thomas-powers-jr/cadence-types` guidance module (phase 77) so the MCP
119
+ // prompts and these slash commands share one source of truth. The
120
+ // command-shape fields (cli, argumentHint, which commands carry a dialogue
121
+ // body) live here so both host adapters render from the identical catalog.
122
+ const g = COMMAND_GUIDANCE;
123
+ export const COMMANDS = [
124
+ {
125
+ name: 'cadence-progress',
126
+ description: g['cadence-progress'].description,
127
+ cli: 'progress',
128
+ trailing: g['cadence-progress'].trailing,
129
+ },
130
+ {
131
+ name: 'cadence-next',
132
+ description: g['cadence-next'].description,
133
+ cli: 'next',
134
+ trailing: g['cadence-next'].trailing,
135
+ },
136
+ {
137
+ name: 'cadence-draft',
138
+ description: g['cadence-draft'].description,
139
+ argumentHint: '<phase-id> <task-num> [--title=<title>]',
140
+ cli: 'draft new $ARGUMENTS',
141
+ trailing: g['cadence-draft'].trailing,
142
+ },
143
+ {
144
+ name: 'cadence-approve',
145
+ description: g['cadence-approve'].description,
146
+ argumentHint: '<phase-id> <task-num>',
147
+ cli: 'draft approve $ARGUMENTS',
148
+ trailing: g['cadence-approve'].trailing,
149
+ },
150
+ {
151
+ name: 'cadence-check',
152
+ description: g['cadence-check'].description,
153
+ argumentHint: '<phase-id> <task-num>',
154
+ cli: 'draft check $ARGUMENTS',
155
+ trailing: g['cadence-check'].trailing,
156
+ },
157
+ {
158
+ name: 'cadence-build',
159
+ description: g['cadence-build'].description,
160
+ argumentHint: '<task-id> --status=<PASS|FAIL|BLOCKED|ESCALATED>',
161
+ cli: 'build task $ARGUMENTS',
162
+ trailing: g['cadence-build'].trailing,
163
+ },
164
+ {
165
+ name: 'cadence-settle',
166
+ description: g['cadence-settle'].description,
167
+ argumentHint: '[--ac AC-1=pass ...]',
168
+ cli: 'settle run $ARGUMENTS',
169
+ trailing: g['cadence-settle'].trailing,
170
+ },
171
+ {
172
+ name: 'cadence-done',
173
+ description: g['cadence-done'].description,
174
+ argumentHint: '<task-id> [--notes=<n>]',
175
+ cli: 'done $ARGUMENTS',
176
+ trailing: g['cadence-done'].trailing,
177
+ },
178
+ {
179
+ name: 'cadence-block',
180
+ description: g['cadence-block'].description,
181
+ argumentHint: '<task-id> [--notes=<n>]',
182
+ cli: 'block $ARGUMENTS',
183
+ trailing: g['cadence-block'].trailing,
184
+ },
185
+ {
186
+ name: 'cadence-needs-context',
187
+ description: g['cadence-needs-context'].description,
188
+ argumentHint: '<task-id> [--notes=<n>]',
189
+ cli: 'needs-context $ARGUMENTS',
190
+ trailing: g['cadence-needs-context'].trailing,
191
+ },
192
+ {
193
+ name: 'cadence-handoff',
194
+ description: g['cadence-handoff'].description,
195
+ argumentHint: '[label]',
196
+ cli: 'handoff $ARGUMENTS',
197
+ trailing: g['cadence-handoff'].trailing,
198
+ },
199
+ {
200
+ name: 'cadence-resume',
201
+ description: g['cadence-resume'].description,
202
+ cli: 'resume',
203
+ trailing: g['cadence-resume'].trailing,
204
+ },
205
+ {
206
+ name: 'cadence-recommend',
207
+ description: g['cadence-recommend'].description,
208
+ argumentHint: '[count]',
209
+ cli: 'recommend --top 5',
210
+ trailing: g['cadence-recommend'].trailing,
211
+ },
212
+ {
213
+ name: 'cadence-scout',
214
+ description: g['cadence-scout'].description,
215
+ argumentHint: '[topic]',
216
+ cli: 'recommend',
217
+ body: SCOUT_DIALOGUE,
218
+ },
219
+ {
220
+ name: 'cadence-dispatch',
221
+ description: g['cadence-dispatch'].description,
222
+ cli: 'dispatch plan --json',
223
+ body: DISPATCH_DIALOGUE,
224
+ },
225
+ ];
226
+ //# sourceMappingURL=routing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"routing.js","sourceRoot":"","sources":["../src/routing.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,iCAAiC,CAAC;AAMtG,8EAA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AmB,CAAC,CAAC,QAAQ;KAC1C;IACD;QACE,IAAI,EAAE,eAAe;QACrB,WAAW,EAAE,CAAC,CAAC,eAAe,CAAC,CAAC,WAAW;QAC3C,YAAY,EAAE,SAAS;QACvB,GAAG,EAAE,WAAW;QAChB,IAAI,EAAE,cAAc;KACrB;IACD;QACE,IAAI,EAAE,kBAAkB;QACxB,WAAW,EAAE,CAAC,CAAC,kBAAkB,CAAC,CAAC,WAAW;QAC9C,GAAG,EAAE,sBAAsB;QAC3B,IAAI,EAAE,iBAAiB;KACxB;CACF,CAAC"}
package/package.json ADDED
@@ -0,0 +1,61 @@
1
+ {
2
+ "name": "@thomas-powers-jr/cadence-host-toolkit",
3
+ "version": "1.54.0",
4
+ "engines": {
5
+ "node": ">=22"
6
+ },
7
+ "description": "Shared toolkit for CADENCE host adapters — the hook-event routing algorithm and the slash-command catalog used by host-claude-code and host-codex.",
8
+ "license": "MIT",
9
+ "author": "Thomas Powers",
10
+ "homepage": "https://github.com/thomas-powers-jr/cadence#readme",
11
+ "bugs": "https://github.com/thomas-powers-jr/cadence/issues",
12
+ "keywords": [
13
+ "cadence",
14
+ "host-adapter",
15
+ "toolkit",
16
+ "hooks",
17
+ "slash-commands"
18
+ ],
19
+ "type": "module",
20
+ "main": "./dist/routing.js",
21
+ "types": "./dist/routing.d.ts",
22
+ "exports": {
23
+ ".": {
24
+ "import": "./dist/routing.js",
25
+ "types": "./dist/routing.d.ts"
26
+ },
27
+ "./locate-self": {
28
+ "import": "./dist/locate-self.js",
29
+ "types": "./dist/locate-self.d.ts"
30
+ },
31
+ "./install-merge": {
32
+ "import": "./dist/install-merge.js",
33
+ "types": "./dist/install-merge.d.ts"
34
+ }
35
+ },
36
+ "files": [
37
+ "dist",
38
+ "!dist/tsconfig.tsbuildinfo"
39
+ ],
40
+ "publishConfig": {
41
+ "access": "public"
42
+ },
43
+ "repository": {
44
+ "type": "git",
45
+ "url": "git+https://github.com/thomas-powers-jr/cadence.git",
46
+ "directory": "packages/host-toolkit"
47
+ },
48
+ "dependencies": {
49
+ "@thomas-powers-jr/cadence-types": "1.54.0"
50
+ },
51
+ "devDependencies": {
52
+ "vitest": "^2.1.0"
53
+ },
54
+ "scripts": {
55
+ "build": "tsc -p tsconfig.json",
56
+ "typecheck": "tsc -p tsconfig.json --noEmit",
57
+ "test": "vitest run",
58
+ "lint": "eslint src",
59
+ "clean": "rm -rf dist .turbo"
60
+ }
61
+ }