halfcycle 0.3.36 → 0.3.37
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/.claude-plugin/plugin.json +1 -1
- package/README.md +3 -1
- package/bin/bin.bundle.mjs +260 -81
- package/dist/bin.js +162 -138
- package/dist/bin.js.map +3 -3
- package/dist/device-signin.d.ts +93 -17
- package/dist/device-signin.d.ts.map +1 -1
- package/dist/engagement-credential.d.ts +8 -4
- package/dist/engagement-credential.d.ts.map +1 -1
- package/dist/index.js +40 -63
- package/dist/index.js.map +3 -3
- package/dist/install.d.ts +2 -8
- package/dist/install.d.ts.map +1 -1
- package/dist/loopback-signin.d.ts +8 -2
- package/dist/loopback-signin.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/device-signin.d.ts
CHANGED
|
@@ -10,8 +10,11 @@
|
|
|
10
10
|
* SINCE T-25 THERE ARE TWO WAYS THE ANSWER COMES BACK, and `signIn` below is where
|
|
11
11
|
* the choice is made:
|
|
12
12
|
*
|
|
13
|
-
* LOOPBACK (the default) — the CLI listens on `127.0.0.1
|
|
14
|
-
* browser back to it,
|
|
13
|
+
* LOOPBACK (the default) — the CLI listens on `127.0.0.1` and the page redirects the
|
|
14
|
+
* browser back to it, while this file polls control beside that wait, so a sign-in
|
|
15
|
+
* approved on any tab or device completes. The user code is printed for a plain
|
|
16
|
+
* tab to be compared against; the loopback page shows none. `loopback-signin.ts`
|
|
17
|
+
* owns the listener.
|
|
15
18
|
*
|
|
16
19
|
* DEVICE CODE (the fallback) — the code is printed, the human compares it with the
|
|
17
20
|
* page, and this file polls. Unchanged, and the right answer whenever the browser
|
|
@@ -59,6 +62,7 @@
|
|
|
59
62
|
*
|
|
60
63
|
* INV-001: Node builtins, the global `fetch` (Node 20), and `@halfcycle/events`.
|
|
61
64
|
*/
|
|
65
|
+
import { spawn } from 'node:child_process';
|
|
62
66
|
import { type DeviceAuthStartResponse, type DevicePollApproved } from '@halfcycle/events';
|
|
63
67
|
/**
|
|
64
68
|
* A sign-in that ended without a credential.
|
|
@@ -101,6 +105,8 @@ export interface SignInDeps {
|
|
|
101
105
|
sleep?: (ms: number) => Promise<void>;
|
|
102
106
|
/** The clock the local deadline is measured on. Defaults to `Date.now`. */
|
|
103
107
|
now?: () => number;
|
|
108
|
+
/** How often either wait says it is still waiting. Defaults to fifteen seconds. */
|
|
109
|
+
stillWaitingMs?: number;
|
|
104
110
|
/**
|
|
105
111
|
* What signing in is FOR, spliced into `signIn`'s opening line: "Halfcycle needs
|
|
106
112
|
* an account before it can **<reason>** — signing you in through your browser."
|
|
@@ -126,22 +132,42 @@ export interface SignInDeps {
|
|
|
126
132
|
onwardEngagementId?: string;
|
|
127
133
|
}
|
|
128
134
|
/**
|
|
129
|
-
* The platform command that opens a URL in the user's browser, as
|
|
135
|
+
* The platform command that opens a URL in the user's browser, as
|
|
136
|
+
* `{command, args, windowsVerbatimArguments?}`.
|
|
130
137
|
*
|
|
131
138
|
* A PURE FUNCTION so the argv can be asserted on every platform from any platform —
|
|
132
139
|
* the alternative is a test that only ever checks the branch it happens to be
|
|
133
140
|
* running on, which on this repo's CI would mean the Windows and Linux arms were
|
|
134
141
|
* never looked at.
|
|
135
142
|
*
|
|
136
|
-
* NO SHELL, EVER. The URL is an argv element
|
|
137
|
-
* metacharacters is an odd URL and
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
143
|
+
* macOS and Linux: NO SHELL, EVER. The URL is an argv element handed straight to
|
|
144
|
+
* `open`/`xdg-open`, so a value containing shell metacharacters is an odd URL and
|
|
145
|
+
* not a command.
|
|
146
|
+
*
|
|
147
|
+
* `win32` (CHANGED — windows-install-hygiene AC5, the 2026-10-07 walk's F10): the
|
|
148
|
+
* old form, `{ command: 'cmd', args: ['/c', 'start', '', url] }`, hands `cmd.exe` an
|
|
149
|
+
* argv array it reassembles into one command line of its own, and that reassembly
|
|
150
|
+
* quotes nothing — `cmd.exe` then treats an unescaped `&` in the URL as a command
|
|
151
|
+
* separator. The loopback address carries `port` and `state` after a literal `&`
|
|
152
|
+
* (`loopbackVerificationUrl`), so the walk saw the first launch open the address cut
|
|
153
|
+
* at its first `&`, exit 1, and the fallback open a second tab.
|
|
154
|
+
*
|
|
155
|
+
* The fix routes through `cmd.exe` the way `probeClaudeCodeVersion`
|
|
156
|
+
* (`claude-version-probe.ts`) already does for AC3: one argv element carries the
|
|
157
|
+
* ENTIRE inner command as a single quoted string, and `/d /s` plus
|
|
158
|
+
* `windowsVerbatimArguments: true` tell `cmd.exe` to strip only the outer pair of
|
|
159
|
+
* quotes and run what is left — `start "" "<url>"`, the URL still inside its own
|
|
160
|
+
* quotes, which is what keeps `&`, `|`, `^`, `!` and a space inside one pair of
|
|
161
|
+
* quotes rather than cut at the first one. `openBrowser` refuses to build this at
|
|
162
|
+
* all for a URL holding `"` or `%` (see `hasWin32UnsafeOpenerChars`) — a `"` would
|
|
163
|
+
* close the quoted command early, and `cmd.exe` expands `%` as an
|
|
164
|
+
* environment-variable reference regardless of quoting, so quoting the URL does
|
|
165
|
+
* not defend against either.
|
|
141
166
|
*/
|
|
142
167
|
export declare function browserOpenCommand(os: string, url: string): {
|
|
143
168
|
command: string;
|
|
144
169
|
args: string[];
|
|
170
|
+
windowsVerbatimArguments?: boolean;
|
|
145
171
|
};
|
|
146
172
|
/**
|
|
147
173
|
* Is this URL safe to hand to the platform opener?
|
|
@@ -153,6 +179,37 @@ export declare function browserOpenCommand(os: string, url: string): {
|
|
|
153
179
|
* document and a handler-scheme URL would launch whatever claims that scheme.
|
|
154
180
|
*/
|
|
155
181
|
export declare function isOpenableUrl(url: string): boolean;
|
|
182
|
+
/**
|
|
183
|
+
* Does this URL hold a `"`, a `%`, or a C0/DEL control character (U+0000–U+001F,
|
|
184
|
+
* U+007F) — the bytes `cmd.exe` still interprets, or that reach it unaccounted
|
|
185
|
+
* for, inside the single-quoted command `browserOpenCommand`'s `win32` arm builds
|
|
186
|
+
* (windows-install-hygiene AC5; the control-character case added at the
|
|
187
|
+
* windows-client follow-up wave's T-28 review)?
|
|
188
|
+
*
|
|
189
|
+
* A `"` closes that quoted command early, handing `cmd.exe` the remainder of the
|
|
190
|
+
* URL as a second command. A `%` is expanded by `cmd.exe`'s own command-line
|
|
191
|
+
* parser as an environment-variable reference — `%PATH%`, `%COMSPEC%` — and that
|
|
192
|
+
* expansion happens whether or not the text sits inside quotes, so quoting the URL
|
|
193
|
+
* does not defend against it.
|
|
194
|
+
*
|
|
195
|
+
* A CONTROL CHARACTER is refused for a different reason, and a line feed is the
|
|
196
|
+
* sharp case: `isOpenableUrl` parses the address with the WHATWG `URL`
|
|
197
|
+
* constructor, which — per spec — strips every ASCII tab and newline from its
|
|
198
|
+
* input before parsing. So an address carrying a raw `\n` passes `isOpenableUrl`
|
|
199
|
+
* looking exactly like the clean URL it would be without one, while the
|
|
200
|
+
* UNSTRIPPED STRING — the one `browserOpenCommand` actually quotes and `spawn`
|
|
201
|
+
* actually hands to `cmd.exe` — still carries the byte inside the quoted command
|
|
202
|
+
* line. No other C0 control character or DEL is reasoned about any more than that
|
|
203
|
+
* one is, so the whole class is refused rather than only the byte a parser
|
|
204
|
+
* happens to delete.
|
|
205
|
+
*
|
|
206
|
+
* Checked only where it matters, by `openBrowser`, and only on `win32`: `open`
|
|
207
|
+
* (macOS) and `xdg-open` (Linux) take the URL as a bare argv element with no shell
|
|
208
|
+
* in between, so none of these bytes does anything there — and percent-encoding
|
|
209
|
+
* is ordinary in an http(s) URL, so refusing `%` on every platform would refuse
|
|
210
|
+
* addresses that are perfectly safe to open outside `cmd.exe`'s quoting.
|
|
211
|
+
*/
|
|
212
|
+
export declare function hasWin32UnsafeOpenerChars(url: string): boolean;
|
|
156
213
|
/** What was MEASURED when this run tried to open a browser. */
|
|
157
214
|
export interface BrowserOpenAttempt {
|
|
158
215
|
/** A browser was launched. Nobody claims the human looked at it. */
|
|
@@ -198,8 +255,25 @@ export interface BrowserOpenAttempt {
|
|
|
198
255
|
* browser over*; honouring it is not a guess about the machine, and the reason
|
|
199
256
|
* reported says so in those words. Nothing else in this flow reads the environment
|
|
200
257
|
* to decide which path to take.
|
|
258
|
+
*
|
|
259
|
+
* ---------------------------------------------------------------------------
|
|
260
|
+
* `os` IS INJECTABLE (ADDED — AC5), DEFAULTING TO THE REAL PLATFORM, for the same
|
|
261
|
+
* reason `browserOpenCommand` takes one: a `win32`-only refusal
|
|
262
|
+
* (`hasWin32UnsafeOpenerChars`) needs to be assertable from this repo's Linux CI
|
|
263
|
+
* without actually having `cmd.exe` on `PATH`. Every existing caller passes two
|
|
264
|
+
* arguments and gets the real platform, unchanged.
|
|
265
|
+
*
|
|
266
|
+
* `spawnImpl` IS INJECTABLE TOO (ADDED — windows-client T-28 review), for a
|
|
267
|
+
* narrower reason: `node:child_process`'s `spawn` is a built-in ESM export and
|
|
268
|
+
* `node:test`'s `mock.method` cannot redefine a core module's property
|
|
269
|
+
* (`TypeError: Cannot redefine property`, measured), so there was no way for a
|
|
270
|
+
* test to observe what options actually reached `spawn` — in particular, that
|
|
271
|
+
* `windowsVerbatimArguments: true` from `browserOpenCommand`'s `win32` arm
|
|
272
|
+
* survived as far as the call rather than being computed and dropped. Every
|
|
273
|
+
* existing caller passes two or three arguments and gets the real `spawn`,
|
|
274
|
+
* unchanged.
|
|
201
275
|
*/
|
|
202
|
-
export declare function openBrowser(url: string, env?: NodeJS.ProcessEnv): Promise<BrowserOpenAttempt>;
|
|
276
|
+
export declare function openBrowser(url: string, env?: NodeJS.ProcessEnv, os?: string, spawnImpl?: typeof spawn): Promise<BrowserOpenAttempt>;
|
|
203
277
|
/** True iff this run has no human at the keyboard. */
|
|
204
278
|
export declare function isNonInteractive(env?: NodeJS.ProcessEnv): boolean;
|
|
205
279
|
/** `POST /auth/device/start` — mint a code. Throws `SignInRefused` on a refusal. */
|
|
@@ -237,10 +311,12 @@ export declare const LOOPBACK_TIMEOUT_MESSAGE: string;
|
|
|
237
311
|
* ---------------------------------------------------------------------------
|
|
238
312
|
* THE TWO PATHS, AND HOW THE CHOICE BETWEEN THEM IS MADE.
|
|
239
313
|
*
|
|
240
|
-
* LOOPBACK — bind `127.0.0.1:0`, put that port in the URL we open, and
|
|
241
|
-
* the confirmation page to send the browser back
|
|
242
|
-
* (
|
|
243
|
-
*
|
|
314
|
+
* LOOPBACK — bind `127.0.0.1:0`, put that port in the URL we open, and poll
|
|
315
|
+
* control while waiting for the confirmation page to send the browser back
|
|
316
|
+
* (`pollBesideLoopback`; the redirect only wakes the poll). The USER code is
|
|
317
|
+
* printed: the loopback page shows none, but a plain sign-in tab does, and asks
|
|
318
|
+
* whether it matches this terminal. *This replaces T-25's "no code is displayed
|
|
319
|
+
* at all", withdrawn by the walk-F3 amendment of 2026-10-08.*
|
|
244
320
|
*
|
|
245
321
|
* DEVICE CODE — print the code, open (or print) the page, and poll. Unchanged from
|
|
246
322
|
* T-08, still tested, and still correct for every machine whose browser is not the
|
|
@@ -267,10 +343,10 @@ export declare const LOOPBACK_TIMEOUT_MESSAGE: string;
|
|
|
267
343
|
* to a connection error after a successful approval — a page that looks broken for a
|
|
268
344
|
* sign-in that worked.
|
|
269
345
|
*
|
|
270
|
-
* WHAT IS PRINTED AND WHAT IS NOT, on
|
|
271
|
-
*
|
|
272
|
-
*
|
|
273
|
-
*
|
|
346
|
+
* WHAT IS PRINTED AND WHAT IS NOT, on BOTH paths: the USER code is printed — it is a
|
|
347
|
+
* selector a human compares between two screens and yields nothing to whoever reads
|
|
348
|
+
* it, since only the device code can claim the credential. The DEVICE code and the
|
|
349
|
+
* credential are printed nowhere, ever, and appear in no URL.
|
|
274
350
|
*/
|
|
275
351
|
export declare function signIn(serviceUrl: string, deps?: SignInDeps & {
|
|
276
352
|
env?: NodeJS.ProcessEnv;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"device-signin.d.ts","sourceRoot":"","sources":["../src/device-signin.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"device-signin.d.ts","sourceRoot":"","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H,wBAAsB,MAAM,CAC1B,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,UAAU,GAAG;IAAE,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAA;CAAO,GAClD,OAAO,CAAC,QAAQ,CAAC,CA0FnB"}
|
|
@@ -247,10 +247,14 @@ export declare const GUARD_ENV_KEYS: readonly ["GUARD_SERVICE_URL", "GUARD_SERVI
|
|
|
247
247
|
* keeps the two bound: add a fourth guard variable to `GUARD_ENV_KEYS` and it
|
|
248
248
|
* appears here, required, without anybody remembering this constant exists.
|
|
249
249
|
*
|
|
250
|
-
* The consumer is the
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
*
|
|
250
|
+
* The consumer is the install report, which names the keys a covered repository
|
|
251
|
+
* holds. The generated session-start script used to be a second consumer, looping
|
|
252
|
+
* over this list to decide whether to print the no-coverage banner; since
|
|
253
|
+
* `session-start-connection-check` that banner is the runner's, decided by the
|
|
254
|
+
* guard hook's own `readConfig`, whose required pair this list must keep naming.
|
|
255
|
+
* Naming an address a developer cannot obtain and does not need in a list of what is
|
|
256
|
+
* missing — beside an instruction to re-run the installer — is the wall this whole
|
|
257
|
+
* change removed.
|
|
254
258
|
*/
|
|
255
259
|
export declare const GUARD_COVERAGE_REQUIRED_KEYS: ("GUARD_SERVICE_TOKEN" | "GUARD_ENGAGEMENT_ID")[];
|
|
256
260
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"engagement-credential.d.ts","sourceRoot":"","sources":["../src/engagement-credential.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmGG;AAoBH,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,uBAAuB,EACvB,kBAAkB,EAClB,gCAAgC,EAChC,YAAY,EACZ,GAAG,EACH,OAAO,GACR,MAAM,iB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,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EACjD,IAAI,GAAE,SAAS,MAAM,EAAwB,GAC5C,MAAM,CAER;AAMD;;;;;;;GAOG;AACH,wBAAgB,iBAAiB,CAC/B,YAAY,EAAE,MAAM,EACpB,IAAI,CAAC,EAAE,MAAM,GACZ,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,IAAI,CAM/B;AAED,8DAA8D;AAC9D,MAAM,MAAM,eAAe,GAAG,SAAS,GAAG,SAAS,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,kBAAkB,CAChC,YAAY,EAAE,MAAM,EACpB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,CAAC,EACjD,IAAI,CAAC,EAAE,MAAM,EACb,IAAI,GAAE,SAAS,MAAM,EAAwB,GAC5C,eAAe,CAoBjB;AA4BD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2DG;AACH,wBAAgB,yBAAyB,IAAI,MAAM,CAsDlD"}
|
package/dist/index.js
CHANGED
|
@@ -205,6 +205,10 @@ function looksLikeSecret(text) {
|
|
|
205
205
|
return false;
|
|
206
206
|
}
|
|
207
207
|
|
|
208
|
+
// ../core/dist/mcp-registration.js
|
|
209
|
+
var MCP_REGISTRATION_REL = ".mcp.json";
|
|
210
|
+
var MCP_SERVER_KEY = "halfcycle";
|
|
211
|
+
|
|
208
212
|
// ../events/dist/result.js
|
|
209
213
|
import { z as z2 } from "zod";
|
|
210
214
|
var firedGuardSchema = z2.object({
|
|
@@ -1001,6 +1005,19 @@ var ciTokenExchangeResponseSchema = z7.object({
|
|
|
1001
1005
|
expiresAt: utcIso8601,
|
|
1002
1006
|
engagementId: z7.string()
|
|
1003
1007
|
}).strict();
|
|
1008
|
+
var NO_CREDENTIAL_PLACEHOLDER = "halfcycle:no-credential";
|
|
1009
|
+
var NOT_THIS_ACCOUNT_PLACEHOLDER = "halfcycle:not-this-account";
|
|
1010
|
+
var UPDATE_CLAUDE_CODE_PLACEHOLDER = "halfcycle:update-claude-code";
|
|
1011
|
+
var SWITCH_ACCOUNT_ANSWER = 'answer "s" when asked';
|
|
1012
|
+
var NO_CREDENTIAL_SENTENCE = 'Halfcycle is not connected: this machine has no working Halfcycle credential for this project. Run "npx halfcycle" in the project folder to sign in again.';
|
|
1013
|
+
var NOT_THIS_ACCOUNT_SENTENCE = `Halfcycle is not connected: this project belongs to another Halfcycle account. To switch, run "npx halfcycle" in this project and ${SWITCH_ACCOUNT_ANSWER}.`;
|
|
1014
|
+
var UPDATE_CLAUDE_CODE_SENTENCE = "Halfcycle is not connected: this Claude Code version does not name the server it connects to, so no credential was sent. Update Claude Code, then reopen.";
|
|
1015
|
+
var NO_NODE_SENTENCE = "Halfcycle is not connected: Node is not installed, or not on the path this session uses, so nothing here is checked. Install Node, then reopen.";
|
|
1016
|
+
var PLACEHOLDER_SENTENCES = Object.freeze({
|
|
1017
|
+
[NO_CREDENTIAL_PLACEHOLDER]: NO_CREDENTIAL_SENTENCE,
|
|
1018
|
+
[NOT_THIS_ACCOUNT_PLACEHOLDER]: NOT_THIS_ACCOUNT_SENTENCE,
|
|
1019
|
+
[UPDATE_CLAUDE_CODE_PLACEHOLDER]: UPDATE_CLAUDE_CODE_SENTENCE
|
|
1020
|
+
});
|
|
1004
1021
|
|
|
1005
1022
|
// ../events/dist/phase-record.js
|
|
1006
1023
|
import { z as z8 } from "zod";
|
|
@@ -1720,7 +1737,7 @@ var WRITE_ALLOWLIST = [
|
|
|
1720
1737
|
".halfcycle/bin",
|
|
1721
1738
|
"docs/build-records",
|
|
1722
1739
|
"test/fixtures/captured",
|
|
1723
|
-
|
|
1740
|
+
MCP_REGISTRATION_REL,
|
|
1724
1741
|
".gitattributes",
|
|
1725
1742
|
ZONE_B_DIR
|
|
1726
1743
|
];
|
|
@@ -2093,6 +2110,20 @@ exec node "$PROJECT_DIR/${VENDORED_BIN_REL}" "$@"
|
|
|
2093
2110
|
}
|
|
2094
2111
|
var GENERATED_SESSION_START_HEADER = "# Session-start marker \u2014 generated by";
|
|
2095
2112
|
var SESSION_ID_FROM_HOOK_INPUT_SH = `SESSION_ID="$(printf '%s' "$INPUT" | node -e 'let s="";process.stdin.on("data",d=>s+=d).on("end",()=>{try{const j=JSON.parse(s);process.stdout.write(typeof j.session_id==="string"?j.session_id:"")}catch{process.stdout.write("")}})' 2>/dev/null || true)"`;
|
|
2113
|
+
var REPO_HASH_FROM_ROOT_SH = `HASH="$(printf '%s' "$REPO_ROOT" | node -e 'const c=[];process.stdin.on("data",d=>c.push(d)).on("end",()=>{process.stdout.write(require("node:crypto").createHash("sha256").update(Buffer.concat(c)).digest("hex").slice(0,12))})' 2>/dev/null || true)"`;
|
|
2114
|
+
function noNodeReplyShell() {
|
|
2115
|
+
const reply = JSON.stringify({
|
|
2116
|
+
systemMessage: NO_NODE_SENTENCE,
|
|
2117
|
+
hookSpecificOutput: { hookEventName: "SessionStart", additionalContext: NO_NODE_SENTENCE }
|
|
2118
|
+
});
|
|
2119
|
+
if (reply.includes("'")) {
|
|
2120
|
+
throw new Error("[bundle install] the no-Node notice cannot be single-quoted; refusing to write the session-start script.");
|
|
2121
|
+
}
|
|
2122
|
+
return `if ! command -v node >/dev/null 2>&1; then
|
|
2123
|
+
printf '%s\\n' '${reply}'
|
|
2124
|
+
exit 0
|
|
2125
|
+
fi`;
|
|
2126
|
+
}
|
|
2096
2127
|
function generateSessionStartMarker() {
|
|
2097
2128
|
return `#!/usr/bin/env bash
|
|
2098
2129
|
${GENERATED_SESSION_START_HEADER} the Halfcycle installer.
|
|
@@ -2101,10 +2132,15 @@ ${GENERATED_SESSION_START_HEADER} the Halfcycle installer.
|
|
|
2101
2132
|
# it began instead of only against the latest commit. The session id comes in on
|
|
2102
2133
|
# stdin with the hook input; without one, the older session-less name is written
|
|
2103
2134
|
# and the stop-time check compares against the latest commit as it used to.
|
|
2135
|
+
#
|
|
2136
|
+
# Without Node nothing Halfcycle installs here can run, so this says so once and
|
|
2137
|
+
# writes no marker.
|
|
2138
|
+
${noNodeReplyShell()}
|
|
2104
2139
|
INPUT="$(cat 2>/dev/null || true)"
|
|
2105
2140
|
REPO_ROOT="\${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}"
|
|
2106
2141
|
if [ -z "$REPO_ROOT" ]; then exit 0; fi
|
|
2107
|
-
|
|
2142
|
+
${REPO_HASH_FROM_ROOT_SH}
|
|
2143
|
+
if [ -z "$HASH" ]; then exit 0; fi
|
|
2108
2144
|
${SESSION_ID_FROM_HOOK_INPUT_SH}
|
|
2109
2145
|
MARKER_DIR="\${TMPDIR:-/tmp}"
|
|
2110
2146
|
MARKER_DIR="\${MARKER_DIR%/}" # strip trailing slash (macOS TMPDIR ends in /)
|
|
@@ -2114,64 +2150,6 @@ else
|
|
|
2114
2150
|
MARKER_FILE="\${MARKER_DIR}/halfcycle-session-\${HASH}.ref"
|
|
2115
2151
|
fi
|
|
2116
2152
|
git -C "$REPO_ROOT" rev-parse HEAD > "$MARKER_FILE" 2>/dev/null || true
|
|
2117
|
-
|
|
2118
|
-
# ---------------------------------------------------------------------------
|
|
2119
|
-
# STANDING GUARD-COVERAGE STATEMENT (T-27; two arms since T-02b).
|
|
2120
|
-
#
|
|
2121
|
-
# A repository with no credential on this machine is UNGUARDED: the PostToolUse
|
|
2122
|
-
# hook will find nothing to evaluate with, and it says so once per edit, after
|
|
2123
|
-
# the edit. This says it once, up front, before anything is written \u2014 which is
|
|
2124
|
-
# the one thing a session-start hook can do that nothing else can.
|
|
2125
|
-
#
|
|
2126
|
-
# TWO REASONS TO HAVE NO CREDENTIAL, TWO DIFFERENT THINGS TO SAY (T-02b,
|
|
2127
|
-
# solo-project-ownership \u2014 outcome B). "You have not signed in here yet" is
|
|
2128
|
-
# fixed by re-running the installer; "this is not your project" is permanent,
|
|
2129
|
-
# and the same remedy would send the reader in a circle forever. The two are
|
|
2130
|
-
# told apart by HALFCYCLE_ENV_NOT_THIS_ACCOUNT, set by \`halfcycle_env_file\`
|
|
2131
|
-
# below from a machine-level marker beside the credential store.
|
|
2132
|
-
#
|
|
2133
|
-
# Everything below runs in a SUBSHELL: it sources a credential store, and a
|
|
2134
|
-
# session-start hook must not leak an engagement's variables into whatever the
|
|
2135
|
-
# editor runs next. Any failure inside it is swallowed; this script's exit
|
|
2136
|
-
# status is 0 either way, and the marker above has already been written.
|
|
2137
|
-
# ---------------------------------------------------------------------------
|
|
2138
|
-
${engagementResolutionShell()}
|
|
2139
|
-
|
|
2140
|
-
(
|
|
2141
|
-
if halfcycle_env_file "$REPO_ROOT"; then
|
|
2142
|
-
set -a
|
|
2143
|
-
. "$HALFCYCLE_ENV_FILE"
|
|
2144
|
-
set +a
|
|
2145
|
-
fi
|
|
2146
|
-
if [ "$HALFCYCLE_ENV_NOT_THIS_ACCOUNT" = "1" ]; then
|
|
2147
|
-
# OUTCOME B (T-02b, solo-project-ownership). This is not the missing-keys
|
|
2148
|
-
# case below wearing different words: there is nothing to fix, and the loop
|
|
2149
|
-
# that follows is skipped entirely rather than run and then overridden \u2014 a
|
|
2150
|
-
# repository whose credential is absent for THIS reason must never be told
|
|
2151
|
-
# to re-run the installer, which can never obtain one for it.
|
|
2152
|
-
echo "[halfcycle] This project belongs to another Halfcycle account, so nothing here is checked."
|
|
2153
|
-
echo "[halfcycle] Your work carries on exactly as it would without Halfcycle \u2014 no edit is"
|
|
2154
|
-
echo "[halfcycle] evaluated, and nothing you do is reported as having passed."
|
|
2155
|
-
echo "[halfcycle] Halfcycle is Solo today \u2014 one developer per project \u2014 with Team plans coming."
|
|
2156
|
-
echo "[halfcycle] Ask the project's owner for view access."
|
|
2157
|
-
echo "[halfcycle] If this account is wrong, sign in as the one that owns the project and run"
|
|
2158
|
-
echo "[halfcycle] \\"npx halfcycle\\" again."
|
|
2159
|
-
else
|
|
2160
|
-
hc_missing=""
|
|
2161
|
-
for hc_key in ${GUARD_COVERAGE_REQUIRED_KEYS.join(" ")}; do
|
|
2162
|
-
eval "hc_value=\\\${$hc_key:-}"
|
|
2163
|
-
if [ -z "$hc_value" ]; then hc_missing="$hc_missing $hc_key"; fi
|
|
2164
|
-
done
|
|
2165
|
-
if [ -n "$hc_missing" ]; then
|
|
2166
|
-
echo "[halfcycle] NO GUARD COVERAGE IN THIS REPOSITORY. Nothing will evaluate the edits made in"
|
|
2167
|
-
echo "[halfcycle] this session: this machine has no Halfcycle credential for it, so the guard hook"
|
|
2168
|
-
echo "[halfcycle] has nothing to call with (missing:$hc_missing)."
|
|
2169
|
-
echo "[halfcycle] Run \\"npx halfcycle\\" in this repository to fix it \u2014 it signs you in through your"
|
|
2170
|
-
echo "[halfcycle] browser if needed, writes the credential to \\$HOME/.halfcycle outside this tree,"
|
|
2171
|
-
echo "[halfcycle] and needs nothing configured first."
|
|
2172
|
-
fi
|
|
2173
|
-
fi
|
|
2174
|
-
) 2>/dev/null || true
|
|
2175
2153
|
exit 0
|
|
2176
2154
|
`;
|
|
2177
2155
|
}
|
|
@@ -2187,7 +2165,8 @@ INPUT="$(cat 2>/dev/null || true)"
|
|
|
2187
2165
|
|
|
2188
2166
|
REPO_ROOT="\${CLAUDE_PROJECT_DIR:-$(git rev-parse --show-toplevel 2>/dev/null)}"
|
|
2189
2167
|
if [ -z "$REPO_ROOT" ]; then exit 0; fi
|
|
2190
|
-
|
|
2168
|
+
${REPO_HASH_FROM_ROOT_SH}
|
|
2169
|
+
if [ -z "$HASH" ]; then exit 0; fi
|
|
2191
2170
|
|
|
2192
2171
|
# The session id arrives on stdin as part of the hook payload. Empty when absent.
|
|
2193
2172
|
${SESSION_ID_FROM_HOOK_INPUT_SH}
|
|
@@ -2307,8 +2286,6 @@ function removeRetiredGeneratedFile(targetRepo, rel, headerLineIndex, knownHeade
|
|
|
2307
2286
|
}
|
|
2308
2287
|
return "removed";
|
|
2309
2288
|
}
|
|
2310
|
-
var MCP_REGISTRATION_REL = ".mcp.json";
|
|
2311
|
-
var MCP_SERVER_KEY = "halfcycle";
|
|
2312
2289
|
var MCP_HEADERS_HELPER_COMMAND = `node -e "${[
|
|
2313
2290
|
`const p=require('path'),f=require('fs'),c=require('child_process');`,
|
|
2314
2291
|
`let d=process.cwd();`,
|