token-goat 2.9.26 → 2.9.29
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/README.md +30 -88
- package/SECURITY.md +14 -0
- package/dist/{token-goat-chunk-OZRSREKR.mjs → token-goat-chunk-2AWQ2R5X.mjs} +2 -2
- package/dist/{token-goat-chunk-BH4ZVRB2.mjs → token-goat-chunk-2NNUA2LR.mjs} +4 -4
- package/dist/token-goat-chunk-2WOUYWLM.mjs +955 -0
- package/dist/{token-goat-chunk-IKZLSRII.mjs → token-goat-chunk-435UQTKD.mjs} +5 -3
- package/dist/{token-goat-chunk-62IHOU6L.mjs → token-goat-chunk-44BM7DDQ.mjs} +5 -3
- package/dist/token-goat-chunk-52NSDWYY.mjs +96 -0
- package/dist/{token-goat-chunk-CXBOFPF4.mjs → token-goat-chunk-67BNIKKO.mjs} +32 -18
- package/dist/{token-goat-chunk-XBESNWEX.mjs → token-goat-chunk-6AK46ZT7.mjs} +2 -3
- package/dist/{token-goat-chunk-7SXPJOSZ.mjs → token-goat-chunk-7CPMDFGB.mjs} +166 -40
- package/dist/token-goat-chunk-ASLWOQ3I.mjs +14 -0
- package/dist/{token-goat-chunk-MWID3YOY.mjs → token-goat-chunk-BGYOZ6DO.mjs} +6 -4
- package/dist/{token-goat-chunk-PAV6NNY7.mjs → token-goat-chunk-C5YPNZKQ.mjs} +22 -8
- package/dist/{token-goat-chunk-D2X7XN5M.mjs → token-goat-chunk-CIQ2FTY3.mjs} +23 -242
- package/dist/token-goat-chunk-D4ETHJD6.mjs +246 -0
- package/dist/{token-goat-chunk-7Y6GWTII.mjs → token-goat-chunk-DNRPXHYH.mjs} +25 -17
- package/dist/{token-goat-chunk-L43RKNHA.mjs → token-goat-chunk-DNSPXQXQ.mjs} +2 -2
- package/dist/token-goat-chunk-DPNLUJWB.mjs +220 -0
- package/dist/token-goat-chunk-E4ZOJIZK.mjs +1382 -0
- package/dist/token-goat-chunk-E5TK5DNO.mjs +718 -0
- package/dist/{token-goat-chunk-VVROQBQJ.mjs → token-goat-chunk-EUSDXRXU.mjs} +62 -12
- package/dist/{token-goat-chunk-POOI26O6.mjs → token-goat-chunk-FTP4U4QA.mjs} +12 -8
- package/dist/token-goat-chunk-G23DWHV4.mjs +142 -0
- package/dist/{token-goat-chunk-MDV5VWF4.mjs → token-goat-chunk-G7IWXCFF.mjs} +223 -15
- package/dist/{token-goat-chunk-C2PG4K5D.mjs → token-goat-chunk-GLXRTTLE.mjs} +7 -5
- package/dist/{token-goat-chunk-M6CVNHTW.mjs → token-goat-chunk-H5J3C56Q.mjs} +95 -573
- package/dist/{token-goat-chunk-BAWKGODL.mjs → token-goat-chunk-HNFZZHFW.mjs} +2 -2
- package/dist/{token-goat-chunk-TG5ZPD6B.mjs → token-goat-chunk-HUYUHODZ.mjs} +1036 -759
- package/dist/token-goat-chunk-IVE6U7KV.mjs +53 -0
- package/dist/{token-goat-chunk-ZZT6PVB3.mjs → token-goat-chunk-IVWI2OCK.mjs} +72 -45
- package/dist/{token-goat-chunk-GMOUBOX4.mjs → token-goat-chunk-JTKCQMQA.mjs} +37 -5
- package/dist/{token-goat-chunk-H2CPLEMP.mjs → token-goat-chunk-KOPIR3KZ.mjs} +46 -23
- package/dist/token-goat-chunk-L7H3U27L.mjs +35 -0
- package/dist/{token-goat-chunk-FLEYOCAS.mjs → token-goat-chunk-LZNBQTDK.mjs} +6 -4
- package/dist/token-goat-chunk-MELOKFDJ.mjs +199 -0
- package/dist/{token-goat-chunk-RH27ZSPF.mjs → token-goat-chunk-NMBWLRHW.mjs} +164 -50
- package/dist/{token-goat-chunk-43JFN26X.mjs → token-goat-chunk-O6I2XU4P.mjs} +27 -967
- package/dist/{token-goat-chunk-G6EYO5CD.mjs → token-goat-chunk-ONXH6NZ5.mjs} +2 -87
- package/dist/token-goat-chunk-ORNFMIER.mjs +295 -0
- package/dist/{token-goat-chunk-LHUP4DXZ.mjs → token-goat-chunk-PGTH2U4C.mjs} +1 -1
- package/dist/{token-goat-chunk-5BQ7W7D7.mjs → token-goat-chunk-PKRWMHVP.mjs} +76 -59
- package/dist/{token-goat-chunk-DA43OE7L.mjs → token-goat-chunk-PQ53BSCF.mjs} +1 -1
- package/dist/{token-goat-chunk-STYRLQIW.mjs → token-goat-chunk-PYSUADX4.mjs} +2 -2
- package/dist/{token-goat-chunk-JALB3KWJ.mjs → token-goat-chunk-QO3LXVVR.mjs} +4247 -5005
- package/dist/{token-goat-chunk-L45IWWMC.mjs → token-goat-chunk-RLP6J7WR.mjs} +6 -6
- package/dist/token-goat-chunk-RQGGMPCR.mjs +205 -0
- package/dist/{token-goat-chunk-MBDJR6HU.mjs → token-goat-chunk-RTMVLHWX.mjs} +3708 -4003
- package/dist/{token-goat-chunk-E3K3BTEQ.mjs → token-goat-chunk-S4VSXURL.mjs} +8 -6
- package/dist/{token-goat-chunk-LKSXAMJB.mjs → token-goat-chunk-SE6E4BKJ.mjs} +1 -1
- package/dist/token-goat-chunk-TCQANXYC.mjs +351 -0
- package/dist/token-goat-chunk-TDUT2CL6.mjs +564 -0
- package/dist/{token-goat-chunk-LRIZ7K3F.mjs → token-goat-chunk-TGOXNAHW.mjs} +54 -111
- package/dist/{token-goat-chunk-WNBSCSAI.mjs → token-goat-chunk-UA5BKWWQ.mjs} +1 -1
- package/dist/{token-goat-chunk-RIB6XY2V.mjs → token-goat-chunk-UXSXQQIY.mjs} +1 -1
- package/dist/{token-goat-chunk-7EPYB34H.mjs → token-goat-chunk-VMFWNHGR.mjs} +84 -73
- package/dist/token-goat-chunk-VQ6F6T7X.mjs +36 -0
- package/dist/{token-goat-chunk-5M3NRJD2.mjs → token-goat-chunk-VZQEWRVH.mjs} +6 -4
- package/dist/{token-goat-chunk-OSUFN2FV.mjs → token-goat-chunk-XB5KKOCG.mjs} +5 -25
- package/dist/{token-goat-chunk-6E2IDLHF.mjs → token-goat-chunk-XYWPOSCN.mjs} +57 -615
- package/dist/{token-goat-chunk-CQHY4SL7.mjs → token-goat-chunk-YAGLESS3.mjs} +8 -5
- package/dist/token-goat-chunk-YKSRAWUU.mjs +33 -0
- package/dist/{token-goat-chunk-F2ARFHLJ.mjs → token-goat-chunk-YOOVFPTP.mjs} +2 -2
- package/dist/{token-goat-chunk-EEIDFMEM.mjs → token-goat-chunk-YZAAZU2S.mjs} +12 -3
- package/dist/token-goat-chunk-Z6KBMOBI.mjs +53 -0
- package/dist/{token-goat-chunk-4GEDH2WU.mjs → token-goat-chunk-ZER6EAXZ.mjs} +81 -70
- package/dist/token-goat-hook-client.cjs +475 -0
- package/dist/token-goat-hook-client.mjs +26 -0
- package/dist/token-goat-hook.mjs +31 -21
- package/dist/token-goat.core.mjs +9 -39
- package/docs/C4_RUNTIME_ARCHITECTURE.md +2 -2
- package/docs/cli.md +35 -23
- package/docs/install.md +18 -14
- package/package.json +1 -1
- package/dist/token-goat-chunk-ADMR3QVF.mjs +0 -41
- package/dist/token-goat-chunk-E6B2UFDF.mjs +0 -30
- package/dist/token-goat-chunk-GKZ2US5B.mjs +0 -187
- package/dist/token-goat-chunk-MZTO4FXH.mjs +0 -26
|
@@ -2,26 +2,26 @@ import { createRequire as __cjsRequire } from 'node:module';
|
|
|
2
2
|
const require = __cjsRequire(import.meta.url);
|
|
3
3
|
import {
|
|
4
4
|
renderWebFetchRow
|
|
5
|
-
} from "./token-goat-chunk-
|
|
5
|
+
} from "./token-goat-chunk-G7IWXCFF.mjs";
|
|
6
6
|
import {
|
|
7
7
|
SESSIONS_SUBDIR,
|
|
8
8
|
extractChecklistSection,
|
|
9
9
|
getSkillFilePath,
|
|
10
10
|
listSkills
|
|
11
|
-
} from "./token-goat-chunk-
|
|
11
|
+
} from "./token-goat-chunk-H5J3C56Q.mjs";
|
|
12
12
|
import {
|
|
13
13
|
getBashOutput
|
|
14
|
-
} from "./token-goat-chunk-
|
|
14
|
+
} from "./token-goat-chunk-O6I2XU4P.mjs";
|
|
15
15
|
import {
|
|
16
16
|
loadBlob
|
|
17
|
-
} from "./token-goat-chunk-
|
|
17
|
+
} from "./token-goat-chunk-D4ETHJD6.mjs";
|
|
18
18
|
import {
|
|
19
19
|
resolveProjectRoot
|
|
20
|
-
} from "./token-goat-chunk-
|
|
20
|
+
} from "./token-goat-chunk-TGOXNAHW.mjs";
|
|
21
21
|
import {
|
|
22
22
|
runGit,
|
|
23
23
|
safeSlice
|
|
24
|
-
} from "./token-goat-chunk-
|
|
24
|
+
} from "./token-goat-chunk-XYWPOSCN.mjs";
|
|
25
25
|
import {
|
|
26
26
|
displaySafePath,
|
|
27
27
|
displaySafeText,
|
|
@@ -0,0 +1,205 @@
|
|
|
1
|
+
import { createRequire as __cjsRequire } from 'node:module';
|
|
2
|
+
const require = __cjsRequire(import.meta.url);
|
|
3
|
+
import {
|
|
4
|
+
PROTOCOL_VERSION,
|
|
5
|
+
SERVER_SLOTS,
|
|
6
|
+
configStamp,
|
|
7
|
+
encodeFrame,
|
|
8
|
+
endpointFor,
|
|
9
|
+
envSnapshot,
|
|
10
|
+
frameFits,
|
|
11
|
+
launcherPath,
|
|
12
|
+
mac,
|
|
13
|
+
macMatches,
|
|
14
|
+
markerAgeMs,
|
|
15
|
+
nonce,
|
|
16
|
+
readFrames,
|
|
17
|
+
readMarker,
|
|
18
|
+
readServerKey,
|
|
19
|
+
touchMarker,
|
|
20
|
+
writeFrame
|
|
21
|
+
} from "./token-goat-chunk-DPNLUJWB.mjs";
|
|
22
|
+
import {
|
|
23
|
+
envBool
|
|
24
|
+
} from "./token-goat-chunk-IVE6U7KV.mjs";
|
|
25
|
+
import {
|
|
26
|
+
init_define_import_meta_env
|
|
27
|
+
} from "./token-goat-chunk-A37V4PBF.mjs";
|
|
28
|
+
|
|
29
|
+
// src/hook_client.ts
|
|
30
|
+
init_define_import_meta_env();
|
|
31
|
+
import { spawn } from "node:child_process";
|
|
32
|
+
import * as fs from "node:fs";
|
|
33
|
+
import * as net from "node:net";
|
|
34
|
+
var HANDSHAKE_TIMEOUT_MS = 150;
|
|
35
|
+
var FIND_BUDGET_MS = 300;
|
|
36
|
+
var RESPONSE_TIMEOUT_MS = 12e4;
|
|
37
|
+
var CONTROL_WAIT_MS = 1e4;
|
|
38
|
+
var SPAWN_RETRY_MS = 3e4;
|
|
39
|
+
var DISABLED_MARKER_TTL_MS = 10 * 6e4;
|
|
40
|
+
function attempt(slot, key, request, handshakeMs, dir) {
|
|
41
|
+
return new Promise((resolve) => {
|
|
42
|
+
const socket = net.connect(endpointFor(slot, dir));
|
|
43
|
+
const nc = nonce();
|
|
44
|
+
let dispatched = false;
|
|
45
|
+
let settled = false;
|
|
46
|
+
const finish = (outcome) => {
|
|
47
|
+
if (settled) return;
|
|
48
|
+
settled = true;
|
|
49
|
+
clearTimeout(timer);
|
|
50
|
+
socket.destroy();
|
|
51
|
+
resolve(outcome);
|
|
52
|
+
};
|
|
53
|
+
let timer = setTimeout(() => finish({ kind: "busy" }), handshakeMs);
|
|
54
|
+
socket.on("error", (e) => {
|
|
55
|
+
if (dispatched) finish({ kind: "lost" });
|
|
56
|
+
else finish({ kind: e.code === "ENOENT" || e.code === "ECONNREFUSED" ? "absent" : "refused" });
|
|
57
|
+
});
|
|
58
|
+
socket.on("close", () => finish({ kind: dispatched ? "lost" : "refused" }));
|
|
59
|
+
const control = request.kind === "status" || request.kind === "stop";
|
|
60
|
+
socket.on("connect", () => writeFrame(socket, { t: "hello", v: PROTOCOL_VERSION, nc, ...control ? { ctl: true } : {} }));
|
|
61
|
+
let ns = "";
|
|
62
|
+
readFrames(
|
|
63
|
+
socket,
|
|
64
|
+
(msg) => {
|
|
65
|
+
if (msg["t"] === "busy") return finish({ kind: "busy" });
|
|
66
|
+
if (msg["t"] === "stale") return finish({ kind: "stale" });
|
|
67
|
+
if (msg["t"] === "challenge" && !dispatched) {
|
|
68
|
+
ns = typeof msg["ns"] === "string" ? msg["ns"] : "";
|
|
69
|
+
if (ns === "" || msg["v"] !== PROTOCOL_VERSION || !macMatches(mac(key, "S", nc, ns), msg["mac"])) return finish({ kind: "refused" });
|
|
70
|
+
const body = JSON.stringify(request);
|
|
71
|
+
const frame = encodeFrame({ t: "req", mac: mac(key, "C", nc, ns, body), body });
|
|
72
|
+
if (!frameFits(frame)) return finish({ kind: "oversize" });
|
|
73
|
+
dispatched = true;
|
|
74
|
+
clearTimeout(timer);
|
|
75
|
+
timer = setTimeout(() => finish({ kind: "lost" }), RESPONSE_TIMEOUT_MS);
|
|
76
|
+
socket.write(frame);
|
|
77
|
+
return;
|
|
78
|
+
}
|
|
79
|
+
if (msg["t"] === "res" && dispatched) {
|
|
80
|
+
const body = msg["body"];
|
|
81
|
+
if (typeof body !== "string" || !macMatches(mac(key, "R", nc, ns, body), msg["mac"])) return finish({ kind: "lost" });
|
|
82
|
+
try {
|
|
83
|
+
return finish({ kind: "served", reply: JSON.parse(body) });
|
|
84
|
+
} catch {
|
|
85
|
+
return finish({ kind: "lost" });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
finish({ kind: dispatched ? "lost" : "refused" });
|
|
89
|
+
},
|
|
90
|
+
() => finish({ kind: dispatched ? "lost" : "refused" })
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
function startServer(slot) {
|
|
95
|
+
const launcher = launcherPath();
|
|
96
|
+
const disabled = markerAgeMs("disabled") < DISABLED_MARKER_TTL_MS && readMarker("disabled") === configStamp();
|
|
97
|
+
if (disabled || markerAgeMs(`spawn-${slot}`) < SPAWN_RETRY_MS || !fs.existsSync(launcher)) return;
|
|
98
|
+
touchMarker(`spawn-${slot}`);
|
|
99
|
+
try {
|
|
100
|
+
spawn(process.execPath, [launcher, "hook-server", "run", "--slot", String(slot)], { detached: true, stdio: "ignore", windowsHide: true }).unref();
|
|
101
|
+
} catch {
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function serverEnabled() {
|
|
105
|
+
return envBool("TOKEN_GOAT_HOOK_SERVER", true);
|
|
106
|
+
}
|
|
107
|
+
async function callServer(request, opts = {}) {
|
|
108
|
+
if (!serverEnabled()) return void 0;
|
|
109
|
+
const autostart = opts.autostart !== false;
|
|
110
|
+
const key = readServerKey();
|
|
111
|
+
if (key === void 0) {
|
|
112
|
+
if (autostart) startServer(0);
|
|
113
|
+
return void 0;
|
|
114
|
+
}
|
|
115
|
+
const deadline = Date.now() + FIND_BUDGET_MS;
|
|
116
|
+
for (let slot = 0; slot < SERVER_SLOTS && Date.now() < deadline; slot++) {
|
|
117
|
+
const outcome = await attempt(slot, key, request, opts.handshakeMs ?? HANDSHAKE_TIMEOUT_MS);
|
|
118
|
+
if (outcome.kind === "served") return outcome.reply;
|
|
119
|
+
if (outcome.kind === "lost") return "lost";
|
|
120
|
+
if (outcome.kind === "absent") {
|
|
121
|
+
if (autostart) startServer(slot);
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
if (outcome.kind === "stale" || outcome.kind === "oversize") return void 0;
|
|
125
|
+
}
|
|
126
|
+
return void 0;
|
|
127
|
+
}
|
|
128
|
+
async function relayViaServer(event, input, harnessWaitMs) {
|
|
129
|
+
try {
|
|
130
|
+
const request = {
|
|
131
|
+
kind: "hook",
|
|
132
|
+
event,
|
|
133
|
+
input: typeof input === "string" ? input : JSON.stringify(input),
|
|
134
|
+
elapsedMs: performance.now(),
|
|
135
|
+
env: envSnapshot(),
|
|
136
|
+
cwd: process.cwd()
|
|
137
|
+
};
|
|
138
|
+
if (harnessWaitMs !== void 0) request.harnessWaitMs = harnessWaitMs;
|
|
139
|
+
const reply = await callServer(request);
|
|
140
|
+
if (reply === void 0) return void 0;
|
|
141
|
+
if (reply === "lost" || !reply.ok || !("stdout" in reply)) return "{}";
|
|
142
|
+
return reply.stdout;
|
|
143
|
+
} catch {
|
|
144
|
+
return void 0;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
var WARM_CLI_COMMANDS = /* @__PURE__ */ new Set([
|
|
148
|
+
"answer",
|
|
149
|
+
"brief",
|
|
150
|
+
"changed",
|
|
151
|
+
"exports",
|
|
152
|
+
"imports",
|
|
153
|
+
"map",
|
|
154
|
+
"outline",
|
|
155
|
+
"read",
|
|
156
|
+
"refs",
|
|
157
|
+
"section",
|
|
158
|
+
"semantic",
|
|
159
|
+
"skeleton",
|
|
160
|
+
"symbol"
|
|
161
|
+
]);
|
|
162
|
+
function warmCliEligible(argv) {
|
|
163
|
+
const command = argv[2];
|
|
164
|
+
if (command === void 0 || !WARM_CLI_COMMANDS.has(command) || process.stdout.isTTY === true) return false;
|
|
165
|
+
return !argv.slice(3).some((a) => a === "-" || a === "--stdin" || a === "--help" || a === "-h");
|
|
166
|
+
}
|
|
167
|
+
async function runCliViaServer(argv) {
|
|
168
|
+
if (!warmCliEligible(argv)) return false;
|
|
169
|
+
try {
|
|
170
|
+
const reply = await callServer({ kind: "cli", argv: argv.slice(2), env: envSnapshot(), cwd: process.cwd() });
|
|
171
|
+
if (reply === void 0 || reply === "lost" || !reply.ok || !("stdout" in reply)) return false;
|
|
172
|
+
if (reply.stdout !== "") process.stdout.write(reply.stdout);
|
|
173
|
+
if (reply.stderr !== void 0 && reply.stderr !== "") process.stderr.write(reply.stderr);
|
|
174
|
+
process.exitCode = reply.status ?? 0;
|
|
175
|
+
return true;
|
|
176
|
+
} catch {
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
async function serverStatuses(dir) {
|
|
181
|
+
return (await queryServers("status", dir)).flatMap(({ reply }) => reply.ok && "info" in reply ? [reply.info] : []);
|
|
182
|
+
}
|
|
183
|
+
async function queryServers(kind, dir) {
|
|
184
|
+
const key = readServerKey(dir);
|
|
185
|
+
if (key === void 0) return [];
|
|
186
|
+
const deadline = Date.now() + CONTROL_WAIT_MS;
|
|
187
|
+
const answered = [];
|
|
188
|
+
for (let slot = 0; slot < SERVER_SLOTS; slot++) {
|
|
189
|
+
let outcome = await attempt(slot, key, { kind }, 2e3, dir);
|
|
190
|
+
while (outcome.kind === "busy" && Date.now() < deadline) outcome = await attempt(slot, key, { kind }, 2e3, dir);
|
|
191
|
+
if (outcome.kind === "served") answered.push({ slot, reply: outcome.reply });
|
|
192
|
+
}
|
|
193
|
+
return answered;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export {
|
|
197
|
+
serverEnabled,
|
|
198
|
+
callServer,
|
|
199
|
+
relayViaServer,
|
|
200
|
+
WARM_CLI_COMMANDS,
|
|
201
|
+
warmCliEligible,
|
|
202
|
+
runCliViaServer,
|
|
203
|
+
serverStatuses,
|
|
204
|
+
queryServers
|
|
205
|
+
};
|