@skillstate/core 2.2.0 → 2.2.1
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.
|
@@ -57,14 +57,27 @@ export declare const INTERRUPTED_SESSION_NOTE = "\nPrevious session was interrup
|
|
|
57
57
|
export declare function describeSchema(schema: StateSchema): string;
|
|
58
58
|
/** Options for {@link skillMdBody}. */
|
|
59
59
|
export interface SkillMdBodyOptions {
|
|
60
|
-
/** Brand label woven into the hooks intro ("Claude Code", "Codex"). */
|
|
60
|
+
/** Brand label woven into the hooks intro ("Claude Code", "Codex", "OpenCode"). */
|
|
61
61
|
hostLabel: string;
|
|
62
62
|
/**
|
|
63
63
|
* How the injected state reaches the model, as a predicate:
|
|
64
64
|
* "injected into your context via hooks" (claude) /
|
|
65
|
-
* "provided as developer context" (codex)
|
|
65
|
+
* "provided as developer context" (codex) /
|
|
66
|
+
* "injected into the message list before every model call" (opencode).
|
|
66
67
|
*/
|
|
67
68
|
injectionPhrase: string;
|
|
69
|
+
/**
|
|
70
|
+
* The hook names this host wires, verbatim as they appear in the bullets:
|
|
71
|
+
* claude/codex use UserPromptSubmit + `SessionStart` + `PostToolUse`;
|
|
72
|
+
* opencode uses `messages.transform` + `session.compacting` +
|
|
73
|
+
* `tool.execute.after`. The merge-bullet is omitted when `patchHook` is
|
|
74
|
+
* undefined.
|
|
75
|
+
*/
|
|
76
|
+
hooks: {
|
|
77
|
+
inject: string;
|
|
78
|
+
reInject: string;
|
|
79
|
+
patchHook?: string;
|
|
80
|
+
};
|
|
68
81
|
/** The skill spec — name/instructions/version fill the frontmatter. */
|
|
69
82
|
spec: ProceduralSpec;
|
|
70
83
|
/** State path written into the frontmatter and the body (default `./.skillstate/skillstate.json`). */
|
|
@@ -77,6 +90,10 @@ export interface SkillMdBodyOptions {
|
|
|
77
90
|
* and `injectionPhrase` (how the state reaches the model). OpenCode keeps
|
|
78
91
|
* its own body — its history is trimmed by the plugin, not by hooks, so
|
|
79
92
|
* its Execution Context and Process genuinely differ.
|
|
93
|
+
*
|
|
94
|
+
* HOOK-NEUTRAL: the injected bullets are driven by `options.hooks` so ANY
|
|
95
|
+
* harness (claude/codex hook-wiring, opencode plugin transforms) renders the
|
|
96
|
+
* same canonical Process without forking the body.
|
|
80
97
|
*/
|
|
81
98
|
export declare function skillMdBody(options: SkillMdBodyOptions): string;
|
|
82
99
|
//# sourceMappingURL=prompt-contract.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-contract.d.ts","sourceRoot":"","sources":["../src/prompt-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,oHAC2E,CAAC;AAEpH,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,QAOzB,CAAC;AAEb,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,oIACqG,CAAC;AAEpI;;;GAGG;AACH,eAAO,MAAM,wBAAwB,uGAC4D,CAAC;AAElG;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAOrB,CAAC;AAEb;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,2JACsH,CAAC;AAE3J;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,+GACyE,CAAC;AAE/G;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAQ1D;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,
|
|
1
|
+
{"version":3,"file":"prompt-contract.d.ts","sourceRoot":"","sources":["../src/prompt-contract.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9D;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,oHAC2E,CAAC;AAEpH,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,QAOzB,CAAC;AAEb,mFAAmF;AACnF,eAAO,MAAM,iBAAiB,oIACqG,CAAC;AAEpI;;;GAGG;AACH,eAAO,MAAM,wBAAwB,uGAC4D,CAAC;AAElG;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,QAOrB,CAAC;AAEb;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB,2JACsH,CAAC;AAE3J;;;;;;;GAOG;AACH,eAAO,MAAM,wBAAwB,+GACyE,CAAC;AAE/G;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAQ1D;AAED,uCAAuC;AACvC,MAAM,WAAW,kBAAkB;IACjC,mFAAmF;IACnF,SAAS,EAAE,MAAM,CAAC;IAClB;;;;;OAKG;IACH,eAAe,EAAE,MAAM,CAAC;IACxB;;;;;;OAMG;IACH,KAAK,EAAE;QAAE,MAAM,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAChE,uEAAuE;IACvE,IAAI,EAAE,cAAc,CAAC;IACrB,sGAAsG;IACtG,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,kBAAkB,GAAG,MAAM,CAyE/D"}
|
package/dist/prompt-contract.js
CHANGED
|
@@ -68,10 +68,15 @@ export function describeSchema(schema) {
|
|
|
68
68
|
* and `injectionPhrase` (how the state reaches the model). OpenCode keeps
|
|
69
69
|
* its own body — its history is trimmed by the plugin, not by hooks, so
|
|
70
70
|
* its Execution Context and Process genuinely differ.
|
|
71
|
+
*
|
|
72
|
+
* HOOK-NEUTRAL: the injected bullets are driven by `options.hooks` so ANY
|
|
73
|
+
* harness (claude/codex hook-wiring, opencode plugin transforms) renders the
|
|
74
|
+
* same canonical Process without forking the body.
|
|
71
75
|
*/
|
|
72
76
|
export function skillMdBody(options) {
|
|
73
77
|
const resolvedStatePath = options.statePath ?? './.skillstate/skillstate.json';
|
|
74
|
-
|
|
78
|
+
const patchHook = options.hooks.patchHook;
|
|
79
|
+
const body = [
|
|
75
80
|
'---',
|
|
76
81
|
`name: ${JSON.stringify(options.spec.name)}`,
|
|
77
82
|
`description: ${JSON.stringify(options.spec.instructions)}`,
|
|
@@ -89,41 +94,23 @@ export function skillMdBody(options) {
|
|
|
89
94
|
'',
|
|
90
95
|
`Your execution state lives at \`${resolvedStatePath}\` (per project; a`,
|
|
91
96
|
'session started in $HOME uses `~/.skillstate/global/skillstate.json`).',
|
|
92
|
-
`The skillstate ${options.hostLabel}
|
|
97
|
+
`The skillstate ${options.hostLabel} integration:`,
|
|
93
98
|
'',
|
|
94
99
|
`- the CURRENT state is ${options.injectionPhrase} on every prompt submit`,
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
'',
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
'
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
'
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
'2. Observe the result of your last action.',
|
|
111
|
-
'3. Reason about what to do next, given the state and the observation.',
|
|
112
|
-
'4. Persist progress with the skillstate MCP tool `state.patch` (sparse',
|
|
113
|
-
' patch; set a key to `null` to delete it; dry-run first with',
|
|
114
|
-
' `state.validate` when unsure; `state.diff` shows what changed since',
|
|
115
|
-
' your last look), and/or emit a fenced JSON block with exactly two',
|
|
116
|
-
' keys inside a Bash tool call so the `PostToolUse` hook merges it:',
|
|
117
|
-
'',
|
|
118
|
-
STATE_PATCH_EXAMPLE_JSON,
|
|
119
|
-
'',
|
|
120
|
-
`- ${STATE_PATCH_RULES}`,
|
|
121
|
-
'- Put anything you need to survive into `state_patch`; never rely on',
|
|
122
|
-
' the conversation remembering it.',
|
|
123
|
-
'- `action` names what you will do next (e.g. "continue", "done").',
|
|
124
|
-
'- When the task is done, call state.finalize {status:"completed"} so the',
|
|
125
|
-
' orchestrator knows (state.finalize {status:"failed"} on failure).',
|
|
126
|
-
'',
|
|
127
|
-
].join('\n');
|
|
100
|
+
` (\`${options.hooks.inject}\`) and is re-injected after compaction`,
|
|
101
|
+
` (\`${options.hooks.reInject}\`);`,
|
|
102
|
+
];
|
|
103
|
+
if (patchHook !== undefined) {
|
|
104
|
+
body.push('- watch every Bash tool result and merge a fenced ```json block carrying', ` a \`state_patch\` into the state file (\`${patchHook}\`).`);
|
|
105
|
+
}
|
|
106
|
+
body.push('', 'Sub-agents automatically get isolated state copies (agents/<session-id>);', 'merge them with `agent.merge` when their task completes.', '', 'The injected state is authoritative — history is not reliable. Never', 'reconstruct execution context from the conversation.', '', '## Process', '', '1. Orient yourself: read the injected state, or call the skillstate MCP', ' tools `state.summary` (compact) / `state.get` (full dump).', '2. Observe the result of your last action.', '3. Reason about what to do next, given the state and the observation.', '4. Persist progress with the skillstate MCP tool `state.patch` (sparse', ' patch; set a key to `null` to delete it; dry-run first with', ' `state.validate` when unsure; `state.diff` shows what changed since', ' your last look)');
|
|
107
|
+
if (patchHook !== undefined) {
|
|
108
|
+
body.push(' , and/or emit a fenced JSON block with exactly two', ' keys inside a Bash tool call so the `PostToolUse` hook merges it:', '', STATE_PATCH_EXAMPLE_JSON, '', `- ${STATE_PATCH_RULES}`);
|
|
109
|
+
}
|
|
110
|
+
else {
|
|
111
|
+
body.push(':', '', STATE_PATCH_EXAMPLE_JSON, '', `- ${STATE_PATCH_RULES}`);
|
|
112
|
+
}
|
|
113
|
+
body.push('- Put anything you need to survive into `state_patch`; never rely on', ' the conversation remembering it.', '- `action` names what you will do next (e.g. "continue", "done").', '- When the task is done, call state.finalize {status:"completed"} so the', ' orchestrator knows (state.finalize {status:"failed"} on failure).', '');
|
|
114
|
+
return body.join('\n');
|
|
128
115
|
}
|
|
129
116
|
//# sourceMappingURL=prompt-contract.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prompt-contract.js","sourceRoot":"","sources":["../src/prompt-contract.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GACtC,iHAAiH,CAAC;AAEpH,uEAAuE;AACvE,MAAM,CAAC,MAAM,wBAAwB,GAAG;IACtC,SAAS;IACT,GAAG;IACH,gEAAgE;IAChE,gCAAgC;IAChC,GAAG;IACH,KAAK;CACN,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb,mFAAmF;AACnF,MAAM,CAAC,MAAM,iBAAiB,GAC5B,iIAAiI,CAAC;AAEpI;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GACnC,+FAA+F,CAAC;AAElG;;;;GAIG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,+DAA+D;IAC/D,MAAM,2BAA2B,EAAE;IACnC,EAAE;IACF,wBAAwB;IACxB,EAAE;IACF,iBAAiB;CAClB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAEb;;;;;GAKG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAClC,wJAAwJ,CAAC;AAE3J;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,wBAAwB,GACnC,4GAA4G,CAAC;AAE/G;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,MAAmB;IAChD,MAAM,MAAM,GAAG,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;SAClC,GAAG,CACF,CAAC,CAAC,IAAI,EAAE,KAAK,CAAC,EAAE,EAAE,CAChB,KAAK,IAAI,KAAK,KAAK,CAAC,IAAI,MAAM,KAAK,CAAC,WAAW,IAAI,gBAAgB,EAAE,CACxE;SACA,IAAI,CAAC,IAAI,CAAC,CAAC;IACd,OAAO,cAAc,MAAM,EAAE,CAAC;AAChC,CAAC;
|
|
1
|
+
{"version":3,"file":"prompt-contract.js","sourceRoot":"","sources":["../src/prompt-contract.ts"],"names":[],"mappings":"AAcA;;;;;GAKG;AACH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