@hearsay-tools/squawk 0.18.0-dev.7009 → 0.18.0-dev.7015
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/dist/core/agent-runner.d.ts +13 -1
- package/dist/core/agent-runner.js +1 -0
- package/dist/core/agent-runner.js.map +1 -1
- package/dist/core/claude-cli-runner.d.ts +3 -0
- package/dist/core/claude-cli-runner.js +13 -6
- package/dist/core/claude-cli-runner.js.map +1 -1
- package/dist/core/codex-app-server-runner.d.ts +4 -18
- package/dist/core/codex-app-server-runner.js +43 -45
- package/dist/core/codex-app-server-runner.js.map +1 -1
- package/dist/core/codex-turn-config.d.ts +19 -0
- package/dist/core/codex-turn-config.js +30 -0
- package/dist/core/codex-turn-config.js.map +1 -0
- package/dist/core/omp-runner.d.ts +3 -0
- package/dist/core/omp-runner.js +32 -16
- package/dist/core/omp-runner.js.map +1 -1
- package/dist/core/omp-ui-mapper.d.ts +2 -2
- package/dist/core/omp-ui-mapper.js +21 -2
- package/dist/core/omp-ui-mapper.js.map +1 -1
- package/dist/core/opencode-http.d.ts +2 -0
- package/dist/core/opencode-http.js +25 -0
- package/dist/core/opencode-http.js.map +1 -0
- package/dist/core/opencode-questions.d.ts +3 -0
- package/dist/core/opencode-questions.js +66 -0
- package/dist/core/opencode-questions.js.map +1 -0
- package/dist/core/opencode-server-runner.d.ts +3 -0
- package/dist/core/opencode-server-runner.js +89 -98
- package/dist/core/opencode-server-runner.js.map +1 -1
- package/dist/core/pi-rpc-turn.d.ts +21 -6
- package/dist/core/pi-rpc-turn.js +42 -17
- package/dist/core/pi-rpc-turn.js.map +1 -1
- package/dist/core/pi-rpc-wire.d.ts +5 -0
- package/dist/core/pi-rpc-wire.js +27 -2
- package/dist/core/pi-rpc-wire.js.map +1 -1
- package/dist/core/pi-runner.d.ts +3 -0
- package/dist/core/pi-runner.js +21 -15
- package/dist/core/pi-runner.js.map +1 -1
- package/dist/core/runner-facts.d.ts +21 -0
- package/dist/core/runner-facts.js +5 -0
- package/dist/core/runner-facts.js.map +1 -1
- package/dist/core/skill-trigger.d.ts +10 -0
- package/dist/core/skill-trigger.js +32 -0
- package/dist/core/skill-trigger.js.map +1 -0
- package/dist/core/ui-events.d.ts +7 -0
- package/dist/delegation/routes.d.ts +13 -13
- package/dist/delegation/transport.d.ts +20 -20
- package/dist/server/activity-routes.d.ts +23 -23
- package/dist/server/reports-api.d.ts +2 -2
- package/dist/server/server.d.ts +58 -58
- package/dist/workflows/run/session-events.js +1 -1
- package/dist/workflows/run/session-events.js.map +1 -1
- package/package.json +4 -4
- package/scripts/mock-claude.mjs +18 -3
- package/scripts/mock-codex-app-server.mjs +14 -0
- package/scripts/mock-omp-rpc.mjs +10 -2
- package/scripts/mock-opencode-serve.mjs +37 -0
- package/scripts/mock-pi-rpc.mjs +16 -4
- package/scripts/mock-skill-trigger-data.mjs +168 -0
- package/scripts/mock-skill-trigger.mjs +34 -0
- package/web/dist/assets/{activity-motion-CXY7UQb8.js → activity-motion-DAjCyDzm.js} +1 -1
- package/web/dist/assets/{activity-route-CWdkKOcU.js → activity-route-6spKzFa-.js} +1 -1
- package/web/dist/assets/{commit-diff-panel-CilF4ucO.js → commit-diff-panel-uoyOydBG.js} +1 -1
- package/web/dist/assets/{diff-wu8MI0pe.js → diff-BefwAEc1.js} +2 -2
- package/web/dist/assets/{diff-view-BOeIj6fq.js → diff-view-CXtKy-02.js} +1 -1
- package/web/dist/assets/{file-preview-DDISrpoK.js → file-preview-TYTU1SBo.js} +1 -1
- package/web/dist/assets/{git-toolbar-DSFDBGUd.js → git-toolbar-BwD-ShUL.js} +1 -1
- package/web/dist/assets/{github-DBRyp_7V.js → github-DKC9GSOG.js} +1 -1
- package/web/dist/assets/{global-activity-route-8gXrkEI5.js → global-activity-route-BnUvjKgI.js} +1 -1
- package/web/dist/assets/{index-1Zw2w-1r.js → index-C6UoXbYK.js} +3 -3
- package/web/dist/assets/{preview-pane-connected-B_yXVXFs.js → preview-pane-connected-ZAr18goj.js} +3 -3
- package/web/dist/assets/{repo-git-cpVcsnni.js → repo-git-Y7MKcjLs.js} +1 -1
- package/web/dist/assets/{report-reader-BRw4X5KH.js → report-reader-CIcjK2_U.js} +1 -1
- package/web/dist/assets/{reports-BK0543bM.js → reports-SBr0VYKU.js} +1 -1
- package/web/dist/assets/{run-header-CZhtodUg.js → run-header-BSohU_tW.js} +1 -1
- package/web/dist/assets/{skills-0Az8jsnI.js → skills-B_NKCTPq.js} +1 -1
- package/web/dist/assets/{task-changes-jjPRV2ul.js → task-changes-Ozgv3HxN.js} +1 -1
- package/web/dist/assets/{task-commits-CxJKFd3j.js → task-commits-BxAERDIz.js} +1 -1
- package/web/dist/assets/{task-files-Ddk24Oe-.js → task-files-V84lmxj2.js} +1 -1
- package/web/dist/assets/{task-github-item-D49mwA5b.js → task-github-item-CByJ7mYg.js} +1 -1
- package/web/dist/assets/{task-thread-BlVvC3Mo.js → task-thread-C6v4ddX-.js} +9 -9
- package/web/dist/assets/thread-state-ni3Us7DE.js +4 -0
- package/web/dist/assets/{use-hand-to-agent-state-Cgc4s3aK.js → use-hand-to-agent-state-W5nhKd6-.js} +1 -1
- package/web/dist/assets/{workflows-BW6W8C0F.js → workflows-Cb0BDqy5.js} +1 -1
- package/web/dist/index.html +1 -1
- package/web/dist/assets/thread-state-DfIi2HR7.js +0 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hearsay-tools/squawk",
|
|
3
|
-
"version": "0.18.0-dev.
|
|
3
|
+
"version": "0.18.0-dev.7015",
|
|
4
4
|
"description": "Local cockpit for running and tracking AI agent tasks in your repo. Uses your logged-in `claude` CLI and `gh` — zero config, zero database.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -63,8 +63,8 @@
|
|
|
63
63
|
"devDependencies": {
|
|
64
64
|
"@babel/parser": "^8.0.8",
|
|
65
65
|
"@babel/types": "^8.0.8",
|
|
66
|
-
"@open-mercato/cezar-api-client": "0.18.0-dev.
|
|
67
|
-
"@open-mercato/cezar-contract": "0.18.0-dev.
|
|
66
|
+
"@open-mercato/cezar-api-client": "0.18.0-dev.7015",
|
|
67
|
+
"@open-mercato/cezar-contract": "0.18.0-dev.7015",
|
|
68
68
|
"@types/node": "^24.19.1",
|
|
69
69
|
"@types/ws": "^8.18.1",
|
|
70
70
|
"esbuild": "^0.28.1",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
"publishConfig": {
|
|
82
82
|
"access": "public"
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "caf0e3eaae00e71d190d596bb8daf8b59fdc0850"
|
|
85
85
|
}
|
package/scripts/mock-claude.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { claudeTrigger, skillFrames, knownSkill, SKILL_TOKEN } from './mock-skill-trigger.mjs';
|
|
2
3
|
import { productEnv } from './product-env.mjs';
|
|
3
4
|
import { CLAUDE_FAILURES } from './mock-provider-failures.mjs';
|
|
4
5
|
import { loadControls } from './mock-controls.mjs';
|
|
@@ -82,7 +83,8 @@ if (process.env.CEZ_MOCK_ARGS_FILE) {
|
|
|
82
83
|
}
|
|
83
84
|
|
|
84
85
|
if (process.env.CEZ_MOCK_CI_PR) { const { probeCiTool } = await import('./mock-ci-tool.mjs'); await probeCiTool('claude', process.argv.slice(2)); }
|
|
85
|
-
|
|
86
|
+
const sessionFlag = process.argv.includes('--resume') ? '--resume' : '--session-id';
|
|
87
|
+
emit({ type: 'system', subtype: 'init', session_id: process.argv[process.argv.indexOf(sessionFlag) + 1] ?? 'session_mock' });
|
|
86
88
|
|
|
87
89
|
let turn = 0;
|
|
88
90
|
const scenarioContext = {
|
|
@@ -773,6 +775,8 @@ rl.on('line', (line) => {
|
|
|
773
775
|
let userText = '(unparseable message)';
|
|
774
776
|
let imageCount = 0;
|
|
775
777
|
let uuid;
|
|
778
|
+
let trigger;
|
|
779
|
+
let skillBlocks;
|
|
776
780
|
try {
|
|
777
781
|
const msg = JSON.parse(trimmed);
|
|
778
782
|
if (isSkillListRequest(msg)) {
|
|
@@ -797,6 +801,8 @@ rl.on('line', (line) => {
|
|
|
797
801
|
const blocks = msg?.message?.content ?? [];
|
|
798
802
|
userText = blocks.filter((b) => b.type === 'text').map((b) => b.text).join('\n') || '(no text)';
|
|
799
803
|
imageCount = blocks.filter((b) => b.type === 'image').length;
|
|
804
|
+
trigger = claudeTrigger(blocks);
|
|
805
|
+
skillBlocks = blocks;
|
|
800
806
|
} catch {
|
|
801
807
|
// keep placeholders
|
|
802
808
|
}
|
|
@@ -807,7 +813,7 @@ rl.on('line', (line) => {
|
|
|
807
813
|
// text this hook captures.
|
|
808
814
|
if (process.env.CEZ_MOCK_STDIN_FILE) {
|
|
809
815
|
try {
|
|
810
|
-
appendFileSync(process.env.CEZ_MOCK_STDIN_FILE, `${JSON.stringify({ userText, imageCount })}\n`);
|
|
816
|
+
appendFileSync(process.env.CEZ_MOCK_STDIN_FILE, `${JSON.stringify({ userText, imageCount, ...(trigger ? { blocks: skillBlocks } : {}) })}\n`);
|
|
811
817
|
} catch {
|
|
812
818
|
// best effort — never break the mock over the hook
|
|
813
819
|
}
|
|
@@ -818,7 +824,16 @@ rl.on('line', (line) => {
|
|
|
818
824
|
if (drop && userText.includes(drop) && !(process.env.CEZ_MOCK_DROP_ONCE === '1' && droppedOnce)) { droppedOnce = true; return; }
|
|
819
825
|
userText = answerNudge(withoutSessionContext(userText));
|
|
820
826
|
if (steering) { steering.push({ userText, uuid }); return; }
|
|
821
|
-
queue = queue.then(() =>
|
|
827
|
+
queue = queue.then(() => {
|
|
828
|
+
if (!trigger) return respond(userText, imageCount, uuid);
|
|
829
|
+
respondingUuid = uuid;
|
|
830
|
+
const known = knownSkill('claude', trigger);
|
|
831
|
+
if (known && replay) emit({ ...skillFrames('claude', trigger)[0], uuid, isReplay: true });
|
|
832
|
+
else emitReplay(uuid, userText);
|
|
833
|
+
const text = known ? SKILL_TOKEN : userText;
|
|
834
|
+
emit({ type: 'assistant', message: { role: 'assistant', content: [{ type: 'text', text }] } });
|
|
835
|
+
emit({ type: 'result', subtype: 'success', result: text, usage: { input_tokens: 10, output_tokens: 5 } });
|
|
836
|
+
});
|
|
822
837
|
});
|
|
823
838
|
rl.on('close', () => {
|
|
824
839
|
// EOF = session over; finish any in-flight turn then exit cleanly.
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { knownSkill, skillFrames, SKILL_TOKEN } from './mock-skill-trigger.mjs';
|
|
2
3
|
import { productEnv } from './product-env.mjs';
|
|
3
4
|
import { CODEX_FAILURES } from './mock-provider-failures.mjs';
|
|
4
5
|
import { loadControls } from './mock-controls.mjs';
|
|
@@ -728,6 +729,13 @@ async function handleTurnStart(msg) {
|
|
|
728
729
|
}
|
|
729
730
|
|
|
730
731
|
async function dispatchOpenedTurn(msg, prompt, scenarios) {
|
|
732
|
+
const skill = msg.params?.input?.find(item => item.type === 'skill');
|
|
733
|
+
if (skill) {
|
|
734
|
+
nativeText([knownSkill('codex', { id: skill.name, path: skill.path }) ? SKILL_TOKEN : prompt], `skill_reply_${++echoSerial}`);
|
|
735
|
+
nativeUsage();
|
|
736
|
+
emit({ method: 'turn/completed', params: { threadId: 'th_mock_1', turn: { id: 'turn_mock_1', status: 'completed' } } });
|
|
737
|
+
return;
|
|
738
|
+
}
|
|
731
739
|
const crash = scenarios.get('crash-stderr');
|
|
732
740
|
if (crash && await play(crash, scenarioEncoder(msg, prompt, crash, true)) !== 'continue') return;
|
|
733
741
|
for (const route of turnReplies) {
|
|
@@ -763,6 +771,12 @@ function emitOpeningInput(msg, turnText) {
|
|
|
763
771
|
// The real app-server records the turn's own input as a userMessage item,
|
|
764
772
|
// echoing clientUserMessageId as clientId (probe 0.155.1, #505).
|
|
765
773
|
const opening = { type: 'userMessage', id: `item_user_open_${++steerEchoSerial}`, clientId: msg.params?.clientUserMessageId ?? null, content: [{ type: 'text', text: turnText }] };
|
|
774
|
+
if (msg.params?.input?.some(item => item.type === 'skill')) {
|
|
775
|
+
const skill = msg.params.input.find(item => item.type === 'skill');
|
|
776
|
+
const frame = skillFrames('codex', { id: skill.name, args: turnText })[0];
|
|
777
|
+
opening.content = [...msg.params.input];
|
|
778
|
+
opening.type = frame.params.item.type;
|
|
779
|
+
}
|
|
766
780
|
if (process.env.CEZ_MOCK_CODEX_NO_USER_ITEM !== '1') {
|
|
767
781
|
emit({ method: 'item/started', params: { threadId: 'th_mock_1', turnId: 'turn_mock_1', item: opening } });
|
|
768
782
|
emit({ method: 'item/completed', params: { threadId: 'th_mock_1', turnId: 'turn_mock_1', item: opening } });
|
package/scripts/mock-omp-rpc.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { slashTrigger, skillFrames, knownSkill, SKILL_TOKEN } from './mock-skill-trigger.mjs';
|
|
2
3
|
import { productEnv } from './product-env.mjs';
|
|
3
4
|
import { OMP_FAILURES } from './mock-provider-failures.mjs';
|
|
4
5
|
import { loadControls } from './mock-controls.mjs';
|
|
@@ -155,7 +156,8 @@ function messageUpdate(messageId, event) {
|
|
|
155
156
|
|
|
156
157
|
function userMessage(text) {
|
|
157
158
|
const messageId = `msg-${++messageSeq}`;
|
|
158
|
-
const
|
|
159
|
+
const trigger = slashTrigger(text);
|
|
160
|
+
const message = trigger && knownSkill('omp', trigger) ? skillFrames('omp', trigger)[0].message : { role: 'user', content: [{ type: 'text', text }] };
|
|
159
161
|
write({ type: 'message_start', messageId, message });
|
|
160
162
|
write({ type: 'message_end', messageId, message });
|
|
161
163
|
}
|
|
@@ -221,7 +223,7 @@ function endTurn({ status = 'completed', error, kind, settle = true } = {}) {
|
|
|
221
223
|
for (const steer of readNow) {
|
|
222
224
|
userMessage(steer.message);
|
|
223
225
|
if (status === 'error') providerFailure(kind);
|
|
224
|
-
else assistantText([steer.message], { usage: { input: 1, output: 1, cacheRead: 0, cacheWrite: 0, totalTokens: 2, cost: { total: 0 } } });
|
|
226
|
+
else assistantText([slashTrigger(steer.message) && knownSkill('omp', slashTrigger(steer.message)) ? SKILL_TOKEN : steer.message], { usage: { input: 1, output: 1, cacheRead: 0, cacheWrite: 0, totalTokens: 2, cost: { total: 0 } } });
|
|
225
227
|
}
|
|
226
228
|
write({ type: 'turn_end' });
|
|
227
229
|
write({ type: 'agent_end', messages: [], isTerminal: true, yielded: true });
|
|
@@ -490,6 +492,12 @@ function scenarioEncoder(command, ack, state = { acknowledged: false, opened: fa
|
|
|
490
492
|
|
|
491
493
|
async function prompt(command, sent = command.message) {
|
|
492
494
|
const message = command.message;
|
|
495
|
+
const trigger = slashTrigger(message);
|
|
496
|
+
if (trigger) {
|
|
497
|
+
respond(command); beginTurn(command);
|
|
498
|
+
assistantText([knownSkill('omp', trigger) ? SKILL_TOKEN : message]);
|
|
499
|
+
endTurn(); return;
|
|
500
|
+
}
|
|
493
501
|
// Rejected before admission: OMP's error response only, no prompt_result (rpc-mode.ts).
|
|
494
502
|
if (delivery?.rejects(sent)) { fail(command, 'owned turn rejected'); return; }
|
|
495
503
|
// Every successful admission acknowledges through here, so a configured hold-ack holds it
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { knownSkill, skillFrames, SKILL_TOKEN } from './mock-skill-trigger.mjs';
|
|
2
3
|
import { loadControls } from './mock-controls.mjs';
|
|
3
4
|
import { waitForRelease } from './mock-lifecycle.mjs';
|
|
4
5
|
import { scenarioFor, play, PROVIDER_HOLD_SCENARIOS } from './mock-scenario.mjs';
|
|
@@ -235,6 +236,7 @@ const questions = questionReplies({ send, info, finishText, sessionId: () => SES
|
|
|
235
236
|
let autonomousTurn = 0;
|
|
236
237
|
let autonomousCap = false;
|
|
237
238
|
const bodyRoutes = [
|
|
239
|
+
[(req, url) => req.method === 'POST' && /^\/session\/[^/]+\/command$/.test(url), handleSkillCommand],
|
|
238
240
|
[(req, url) => req.method === 'POST' && /^\/question\/[^/]+\/(reply|reject)$/.test(url), questions.replyToQuestion],
|
|
239
241
|
[(req, url) => req.method === 'POST' && /^\/permission\/([^/]+)\/reply$/.test(url), replyToPermission],
|
|
240
242
|
[(req, url) => req.method === 'GET' && /^\/session\/([^/]+)$/.test(url), replyWithSession],
|
|
@@ -940,3 +942,38 @@ server.listen(0, hostname, () => {
|
|
|
940
942
|
process.stdin.on('end', () => process.exit(0));
|
|
941
943
|
process.stdin.resume();
|
|
942
944
|
process.on('SIGTERM', () => process.exit(0));
|
|
945
|
+
|
|
946
|
+
/** Command route captured on OpenCode 1.19.4: user expansion first, HTTP result at turn end. */
|
|
947
|
+
async function handleSkillCommand(req, res, url, raw) {
|
|
948
|
+
SESSION_ID = url.split('/')[2];
|
|
949
|
+
const body = JSON.parse(raw);
|
|
950
|
+
const trigger = { id: body.command, args: body.arguments };
|
|
951
|
+
if (body.arguments.includes('mock:skill-sse-error')) {
|
|
952
|
+
send({ type: 'session.error', properties: {
|
|
953
|
+
sessionID: SESSION_ID, error: { name: 'UnknownError', data: { message: 'skill rejected before expansion' } },
|
|
954
|
+
} });
|
|
955
|
+
return; // The HTTP response never arrives; only SSE can settle this command.
|
|
956
|
+
}
|
|
957
|
+
if (!knownSkill('opencode', trigger)) {
|
|
958
|
+
if (!body.arguments.includes('mock:http-error-only')) send({ type: 'session.error', properties: {
|
|
959
|
+
sessionID: SESSION_ID, error: { name: 'UnknownError', data: { message: `Command not found: "${body.command}"` } },
|
|
960
|
+
} });
|
|
961
|
+
res.writeHead(500, { 'content-type': 'application/json' }); res.end(JSON.stringify({ error: 'Command not found' })); return;
|
|
962
|
+
}
|
|
963
|
+
if (body.arguments.includes('mock:skill-no-ack')) return;
|
|
964
|
+
turnActive = true;
|
|
965
|
+
for (const frame of skillFrames('opencode', trigger)) {
|
|
966
|
+
const props = frame.properties;
|
|
967
|
+
props.sessionID = SESSION_ID;
|
|
968
|
+
if (props.info) { props.info.sessionID = SESSION_ID; currentUserId = props.info.id; }
|
|
969
|
+
if (props.part) props.part.sessionID = SESSION_ID;
|
|
970
|
+
send(frame);
|
|
971
|
+
}
|
|
972
|
+
if (body.arguments.includes('mock:skill-drop')) res.destroy();
|
|
973
|
+
const gate = /mock:skill-gated (\S+)/.exec(body.arguments)?.[1];
|
|
974
|
+
if (gate) await waitForMockFile(gate);
|
|
975
|
+
send({ type: 'message.updated', properties: { info: info({}) } });
|
|
976
|
+
textPart(`skill_reply_${++echoSerial}`, SKILL_TOKEN);
|
|
977
|
+
send({ type: 'session.idle', properties: { sessionID: SESSION_ID } });
|
|
978
|
+
if (!res.destroyed) { res.writeHead(200, { 'content-type': 'application/json' }); res.end('{}'); }
|
|
979
|
+
}
|
package/scripts/mock-pi-rpc.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
+
import { slashTrigger, skillUserMessage, knownSkill, SKILL_TOKEN } from './mock-skill-trigger.mjs';
|
|
2
3
|
import { PI_FAILURES } from './mock-provider-failures.mjs';
|
|
3
4
|
import { loadControls } from './mock-controls.mjs';
|
|
4
5
|
import { scenarioFor, play } from './mock-scenario.mjs';
|
|
@@ -48,7 +49,7 @@ const sendNow = (value) => {
|
|
|
48
49
|
activeTurn = { steers: [], late: false };
|
|
49
50
|
write(value);
|
|
50
51
|
if (currentPrompt !== undefined && process.env.CEZ_MOCK_PI_NO_USER_START !== '1') {
|
|
51
|
-
const message =
|
|
52
|
+
const message = skillUserMessage('pi', currentPrompt);
|
|
52
53
|
currentPrompt = undefined;
|
|
53
54
|
write({ type: 'message_start', message });
|
|
54
55
|
write({ type: 'message_end', message });
|
|
@@ -75,11 +76,13 @@ function replaySteer(text, failure) {
|
|
|
75
76
|
write({ type: 'agent_start' });
|
|
76
77
|
write({ type: 'turn_start' });
|
|
77
78
|
}
|
|
78
|
-
|
|
79
|
-
write({ type: '
|
|
79
|
+
const message = skillUserMessage('pi', text);
|
|
80
|
+
write({ type: 'message_start', message });
|
|
81
|
+
write({ type: 'message_end', message });
|
|
80
82
|
if (failure) write(failure);
|
|
81
83
|
else {
|
|
82
|
-
|
|
84
|
+
const trigger = slashTrigger(text);
|
|
85
|
+
sendText([trigger && knownSkill('pi', trigger) ? SKILL_TOKEN : text]);
|
|
83
86
|
write({ type: 'message_end', message: { role: 'assistant', usage: { input: 1, output: 1, cacheRead: 0, cacheWrite: 0, cost: { total: 0 } } } });
|
|
84
87
|
}
|
|
85
88
|
}
|
|
@@ -414,6 +417,15 @@ async function handlePromptCommand(command) {
|
|
|
414
417
|
if (scenario?.beforeFailure) return play(scenario, scenarioEncoder(command, scenario));
|
|
415
418
|
if (failureControl && (await failureControl.failureFor(command.message)) === 'provider') return respondProviderError(command);
|
|
416
419
|
if (scenario) return play(scenario, scenarioEncoder(command, scenario));
|
|
420
|
+
const trigger = slashTrigger(command.message);
|
|
421
|
+
if (trigger) {
|
|
422
|
+
send({ id: command.id, type: 'response', command: 'prompt', success: true });
|
|
423
|
+
send({ type: 'agent_start' }); send({ type: 'turn_start' });
|
|
424
|
+
const text = knownSkill('pi', trigger) ? SKILL_TOKEN : command.message;
|
|
425
|
+
send({ type: 'message_update', assistantMessageEvent: { type: 'text_delta', contentIndex: 0, delta: text } });
|
|
426
|
+
send({ type: 'message_end', message: { role: 'assistant', content: [{ type: 'text', text }], stopReason: 'stop' } });
|
|
427
|
+
send({ type: 'agent_settled' }); return;
|
|
428
|
+
}
|
|
417
429
|
return respondDefault(command);
|
|
418
430
|
}
|
|
419
431
|
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
// Native captures from core/__fixtures__/<runner>/skill-trigger.json. See slice2-evidence.md.
|
|
2
|
+
export const captures = {
|
|
3
|
+
"claude": [
|
|
4
|
+
{
|
|
5
|
+
"type": "user",
|
|
6
|
+
"message": {
|
|
7
|
+
"role": "user",
|
|
8
|
+
"content": "<command-message>probe-project</command-message>\n<command-name>/probe-project</command-name>\n<command-args>fixture arguments</command-args>"
|
|
9
|
+
}
|
|
10
|
+
},
|
|
11
|
+
{
|
|
12
|
+
"type": "user",
|
|
13
|
+
"isMeta": true,
|
|
14
|
+
"message": {
|
|
15
|
+
"role": "user",
|
|
16
|
+
"content": [
|
|
17
|
+
{
|
|
18
|
+
"type": "text",
|
|
19
|
+
"text": "Opening context: this is a native skill probe."
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
"type": "text",
|
|
23
|
+
"text": "Base directory for this skill: /probe/repo/.claude/skills/probe-project\n\nReply with exactly TRIGGER-FIXTURE. Do not use any tool.\n\n\nARGUMENTS: fixture arguments"
|
|
24
|
+
}
|
|
25
|
+
]
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "assistant",
|
|
30
|
+
"message": {
|
|
31
|
+
"role": "assistant",
|
|
32
|
+
"content": [
|
|
33
|
+
{
|
|
34
|
+
"type": "text",
|
|
35
|
+
"text": "TRIGGER-FIXTURE"
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
],
|
|
41
|
+
"codex": [
|
|
42
|
+
{
|
|
43
|
+
"method": "item/completed",
|
|
44
|
+
"params": {
|
|
45
|
+
"item": {
|
|
46
|
+
"type": "userMessage",
|
|
47
|
+
"id": "01a1e643-bfff-7ef0-82eb-ce4be47adf26",
|
|
48
|
+
"clientId": null,
|
|
49
|
+
"content": [
|
|
50
|
+
{
|
|
51
|
+
"type": "text",
|
|
52
|
+
"text": "fixture arguments\n\nOpening context: this is a native skill probe.",
|
|
53
|
+
"text_elements": []
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"type": "skill",
|
|
57
|
+
"name": "probe-project",
|
|
58
|
+
"path": "/probe/repo/.agents/skills/probe-project/SKILL.md"
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
},
|
|
62
|
+
"threadId": "01a1e643-bb67-73c2-861d-72bcb2b3aa72",
|
|
63
|
+
"turnId": "01a1e643-bbb2-70c2-9cb8-9b4451cb79b7",
|
|
64
|
+
"completedAtMs": 1794864562177
|
|
65
|
+
},
|
|
66
|
+
"emittedAtMs": 1794864562180
|
|
67
|
+
}
|
|
68
|
+
],
|
|
69
|
+
"opencode": [
|
|
70
|
+
{
|
|
71
|
+
"id": "evt_1e644647c001JBwTUFa85HuwXe",
|
|
72
|
+
"type": "message.updated",
|
|
73
|
+
"properties": {
|
|
74
|
+
"sessionID": "ses_e19bb9f24ffeDLvpKOwIDRYASe",
|
|
75
|
+
"info": {
|
|
76
|
+
"id": "msg_1e6446472001QbxAqCh8Ka3c05",
|
|
77
|
+
"role": "user",
|
|
78
|
+
"sessionID": "ses_e19bb9f24ffeDLvpKOwIDRYASe",
|
|
79
|
+
"time": {
|
|
80
|
+
"created": 1794864604274
|
|
81
|
+
},
|
|
82
|
+
"agent": "build",
|
|
83
|
+
"model": {
|
|
84
|
+
"providerID": "zai-coding-plan",
|
|
85
|
+
"modelID": "glm-5.3-flash",
|
|
86
|
+
"variant": "low"
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
"id": "evt_1e644647f001kxHleStwdpUoJf",
|
|
93
|
+
"type": "message.part.updated",
|
|
94
|
+
"properties": {
|
|
95
|
+
"sessionID": "ses_e19bb9f24ffeDLvpKOwIDRYASe",
|
|
96
|
+
"part": {
|
|
97
|
+
"type": "text",
|
|
98
|
+
"text": "Reply with exactly TRIGGER-FIXTURE. Do not use any tool.\n\n\nBase directory for this skill: /probe/repo/.agents/skills/probe-project\nRelative paths in this skill (e.g., scripts/, references/) are relative to this base directory.\n\nfixture arguments\n\nOpening context: this is a native skill probe.",
|
|
99
|
+
"messageID": "msg_1e6446472001QbxAqCh8Ka3c05",
|
|
100
|
+
"sessionID": "ses_e19bb9f24ffeDLvpKOwIDRYASe",
|
|
101
|
+
"id": "prt_1e644647a001VORV1UrikmnbBw"
|
|
102
|
+
},
|
|
103
|
+
"time": 1794864604287
|
|
104
|
+
}
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
"id": "evt_1e644650a001T722fN64VA9xFq",
|
|
108
|
+
"type": "message.updated",
|
|
109
|
+
"properties": {
|
|
110
|
+
"sessionID": "ses_e19bb9f24ffeDLvpKOwIDRYASe",
|
|
111
|
+
"info": {
|
|
112
|
+
"role": "user",
|
|
113
|
+
"time": {
|
|
114
|
+
"created": 1794864604274
|
|
115
|
+
},
|
|
116
|
+
"agent": "build",
|
|
117
|
+
"model": {
|
|
118
|
+
"providerID": "zai-coding-plan",
|
|
119
|
+
"modelID": "glm-5.3-flash",
|
|
120
|
+
"variant": "low"
|
|
121
|
+
},
|
|
122
|
+
"id": "msg_1e6446472001QbxAqCh8Ka3c05",
|
|
123
|
+
"sessionID": "ses_e19bb9f24ffeDLvpKOwIDRYASe",
|
|
124
|
+
"summary": {
|
|
125
|
+
"diffs": []
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
],
|
|
131
|
+
"pi": [
|
|
132
|
+
{
|
|
133
|
+
"type": "message_start",
|
|
134
|
+
"message": {
|
|
135
|
+
"role": "user",
|
|
136
|
+
"content": [
|
|
137
|
+
{
|
|
138
|
+
"type": "text",
|
|
139
|
+
"text": "<skill name=\"probe-project\" location=\"/probe/repo/.pi/skills/probe-project/SKILL.md\">\nReferences are relative to /probe/repo/.pi/skills/probe-project.\n\nReply with exactly TRIGGER-FIXTURE. Do not use any tool.\n</skill>\n\nfixture arguments\n\nOpening context: this is a native skill probe."
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
"timestamp": 1794864645778
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
],
|
|
146
|
+
"omp": [
|
|
147
|
+
{
|
|
148
|
+
"type": "message_start",
|
|
149
|
+
"message": {
|
|
150
|
+
"role": "custom",
|
|
151
|
+
"customType": "skill-prompt",
|
|
152
|
+
"content": "[IMPORTANT: User invoked the \"probe-project\" skill; follow its instructions. Full skill below.]\n\nReply with exactly TRIGGER-FIXTURE. Do not use any tool.\n\n---\n\n[Skill directory: /probe/repo/.omp/skills/probe-project]\nResolve relative paths in this skill (e.g. `scripts/foo.js`, `templates/config.yaml`) against this absolute directory; read referenced assets and templates; run scripts with the terminal tool when skill instructions call for it.\nUser: fixture arguments",
|
|
153
|
+
"display": true,
|
|
154
|
+
"details": {
|
|
155
|
+
"name": "probe-project",
|
|
156
|
+
"path": "/probe/repo/.omp/skills/probe-project/SKILL.md",
|
|
157
|
+
"args": "fixture arguments",
|
|
158
|
+
"prompt": "/skill:probe-project fixture arguments",
|
|
159
|
+
"lineCount": 1,
|
|
160
|
+
"__queueChipText": "/skill:probe-project fixture arguments"
|
|
161
|
+
},
|
|
162
|
+
"attribution": "user",
|
|
163
|
+
"timestamp": 1794864791306
|
|
164
|
+
},
|
|
165
|
+
"messageId": "msg-3"
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { existsSync } from 'node:fs';
|
|
2
|
+
import { captures } from './mock-skill-trigger-data.mjs';
|
|
3
|
+
export const SKILL_TOKEN = 'TRIGGER-FIXTURE';
|
|
4
|
+
export function slashTrigger(text, prefix = '/skill:') {
|
|
5
|
+
if (!text.startsWith(prefix)) return;
|
|
6
|
+
const match = /^([^\s]+)(?:[ \t]([^]*))?$/.exec(text.slice(prefix.length));
|
|
7
|
+
if (!match?.[1].startsWith('probe-')) return;
|
|
8
|
+
return { id: match[1], args: match[2] ?? '' };
|
|
9
|
+
}
|
|
10
|
+
export function knownSkill(runner, trigger) {
|
|
11
|
+
return trigger.id === 'probe-project' || runner === 'codex' && trigger.id === 'probe-late' && existsSync(trigger.path);
|
|
12
|
+
}
|
|
13
|
+
/** Native payloads are cloned from captured CLI frames, with per-turn identities substituted. */
|
|
14
|
+
export function skillFrames(runner, trigger, context = '') {
|
|
15
|
+
const frames = structuredClone(captures[runner]);
|
|
16
|
+
const nativeArgs = runner === 'pi' ? trigger.args.trim() : runner === 'omp' ? trigger.args.trimEnd() : trigger.args;
|
|
17
|
+
const args = [nativeArgs, context].filter(Boolean).join('\n\n');
|
|
18
|
+
const replace = value => typeof value === 'string' ? value
|
|
19
|
+
.replaceAll('/probe/repo', process.cwd())
|
|
20
|
+
.replaceAll('fixture arguments\n\nOpening context: this is a native skill probe.', args)
|
|
21
|
+
.replaceAll('fixture arguments', nativeArgs)
|
|
22
|
+
.replaceAll('Opening context: this is a native skill probe.', context)
|
|
23
|
+
.replaceAll('probe-project', trigger.id) : value;
|
|
24
|
+
return JSON.parse(JSON.stringify(frames), (_key, value) => replace(value));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function claudeTrigger(blocks) {
|
|
28
|
+
const last = blocks.at(-1);
|
|
29
|
+
return last?.type === 'text' ? slashTrigger(last.text, '/') : undefined;
|
|
30
|
+
}
|
|
31
|
+
export function skillUserMessage(runner, text) {
|
|
32
|
+
const trigger = slashTrigger(text);
|
|
33
|
+
return trigger && knownSkill(runner, trigger) ? skillFrames(runner, trigger)[0].message : { role: 'user', content: [{ type: 'text', text }] };
|
|
34
|
+
}
|