@iowarp/clio-coder 0.3.2 → 0.3.4
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/CHANGELOG.md +269 -458
- package/CONTRIBUTING.md +1 -1
- package/README.md +3 -3
- package/dist/{acp-BIYHVZIM.js → acp-S5R4RR5B.js} +7 -6
- package/dist/{agents-YT6SSRIT.js → agents-P6DMMVZY.js} +24 -21
- package/dist/assets/codewiki.json +1 -1
- package/dist/{auth-5TWEIYDN.js → auth-2XCZLPKS.js} +12 -8
- package/dist/{chunk-GGXXDWE4.js → chunk-22NAGB7X.js} +2 -2
- package/dist/{chunk-WMSVI4G2.js → chunk-2LZI5CAG.js} +133 -13
- package/dist/{chunk-OAO4GE4M.js → chunk-2TZWSW76.js} +2 -2
- package/dist/{chunk-OOJYHWRB.js → chunk-34475P3I.js} +2 -2
- package/dist/{chunk-WVO7V2QY.js → chunk-35MKKU5R.js} +4 -4
- package/dist/{chunk-LBNRH5WM.js → chunk-3HZ5RWN2.js} +5 -5
- package/dist/{chunk-AGYYIBLL.js → chunk-3JLKSKD7.js} +2 -2
- package/dist/{chunk-MBS4V7ZP.js → chunk-4JUF2NNX.js} +7 -7
- package/dist/{chunk-ZDOOVTXZ.js → chunk-4OC57DA6.js} +27 -4
- package/dist/chunk-5M54SPOL.js +926 -0
- package/dist/{chunk-STBPMHSX.js → chunk-7RXG6QRZ.js} +51 -11
- package/dist/{chunk-77VKQEHF.js → chunk-A2GZF7DC.js} +5 -5
- package/dist/{chunk-A3CYT5EX.js → chunk-AD2SYQYC.js} +55 -2
- package/dist/chunk-AOCYTWAV.js +449 -0
- package/dist/chunk-BEY543CS.js +258 -0
- package/dist/{chunk-6N5PTWMY.js → chunk-BP4OYD6A.js} +32 -13
- package/dist/chunk-BPGS2WCQ.js +612 -0
- package/dist/{chunk-J5HN4RYU.js → chunk-BRXQQJFP.js} +8 -8
- package/dist/chunk-CFGTUFWB.js +67 -0
- package/dist/{chunk-CBCAPZAA.js → chunk-E25LMLRW.js} +2 -2
- package/dist/{chunk-G2DE3C7R.js → chunk-EDRHSCIE.js} +4 -4
- package/dist/{chunk-4KLWL3UC.js → chunk-EFADSJET.js} +2 -2
- package/dist/{chunk-M6SHUN7Q.js → chunk-FO5ZOVUY.js} +2 -2
- package/dist/chunk-FYYLNIL5.js +313 -0
- package/dist/{chunk-EPVUXGXG.js → chunk-HV5X7OR2.js} +14 -12
- package/dist/{chunk-TZTZS7QK.js → chunk-HXG4IURW.js} +5 -3
- package/dist/{chunk-IGLFWIYI.js → chunk-K6WL7QZT.js} +3 -3
- package/dist/chunk-K7VKOLQQ.js +15 -0
- package/dist/{chunk-BMEMKKIT.js → chunk-KOHPCX4K.js} +2 -2
- package/dist/{chunk-V4RXGQ5Q.js → chunk-KRPY7NTG.js} +10 -7
- package/dist/chunk-LL4KHSZI.js +22 -0
- package/dist/{chunk-KJ5LWLOE.js → chunk-MEQ45TQ4.js} +15 -9
- package/dist/{chunk-5UUP6MWO.js → chunk-MV3K5QF2.js} +5 -436
- package/dist/{chunk-AO4RKG4M.js → chunk-N4CZJQRK.js} +5 -5
- package/dist/{chunk-ARBGF5F7.js → chunk-NILBFAPG.js} +14 -8
- package/dist/chunk-OZNBF4L3.js +23 -0
- package/dist/{verify-G6V4D2G7.js → chunk-PCZJO5TI.js} +127 -42
- package/dist/chunk-QQK64KLB.js +1360 -0
- package/dist/{chunk-6EJV5X2W.js → chunk-QQL5RT5M.js} +979 -1619
- package/dist/{chunk-LZSJBIVT.js → chunk-QWU7ZBO7.js} +70 -720
- package/dist/{chunk-2EHAIA3X.js → chunk-RD5U66HV.js} +3 -3
- package/dist/{chunk-OKGUZO2U.js → chunk-SPULKLCF.js} +4 -3
- package/dist/{chunk-OQ33BKR3.js → chunk-TTNYS3EA.js} +3 -60
- package/dist/chunk-TW3WDMVS.js +677 -0
- package/dist/chunk-TZSKNMZG.js +434 -0
- package/dist/{chunk-7MNJORFF.js → chunk-UL3WSD3F.js} +6 -1
- package/dist/{chunk-7EYHLWU7.js → chunk-UZHIZC5S.js} +7 -7
- package/dist/{chunk-QTYWRVRA.js → chunk-VAWWTKDP.js} +8 -8
- package/dist/{chunk-X75S7HFS.js → chunk-VEZEGCGW.js} +214 -20
- package/dist/{chunk-OHHN2SO4.js → chunk-VMNQ6OZA.js} +98 -202
- package/dist/chunk-VSNATDE6.js +122 -0
- package/dist/chunk-W6GROXXM.js +69 -0
- package/dist/chunk-WPQLXFOZ.js +375 -0
- package/dist/{chunk-ORBHGJC5.js → chunk-WR67VIZY.js} +3 -3
- package/dist/{chunk-3ZXDFGR5.js → chunk-X6COSD2O.js} +5 -5
- package/dist/chunk-ZGVHUX3M.js +66 -0
- package/dist/{chunk-MAW544W2.js → chunk-ZWMF7253.js} +4 -4
- package/dist/{chunk-MQSRRFWA.js → chunk-ZYKPLLNQ.js} +563 -546
- package/dist/cli/index.js +27 -23
- package/dist/{clio-4LY5K2AC.js → clio-J5JIOIDS.js} +7 -6
- package/dist/{code-nav-7AX6FYE6.js → code-nav-AXCXSBHX.js} +5 -3
- package/dist/{config-GTLUW2PR.js → config-OEBMIN2U.js} +37 -27
- package/dist/{configure-R6A64DHX.js → configure-PUQOSIXQ.js} +16 -13
- package/dist/{context-5VKGUVJJ.js → context-EKDCKUUZ.js} +82 -7
- package/dist/{context-RW5HC47S.js → context-MGSE4Z2T.js} +33 -23
- package/dist/{context-JFZEJ7W5.js → context-URSXPBCK.js} +17 -9
- package/dist/{context-clear-6ZHBAZZT.js → context-clear-KDAJRNUK.js} +33 -23
- package/dist/context-working-set-SBKMPPI2.js +1552 -0
- package/dist/{dispatch-runner-VKBRCWQC.js → dispatch-runner-MSWN72NK.js} +43 -29
- package/dist/{doctor-KI767GSN.js → doctor-7BSE27PJ.js} +10 -10
- package/dist/{eval-XSSNATB4.js → eval-IZGDOO4H.js} +9 -8
- package/dist/{evidence-UA6AWDQQ.js → evidence-SR7WXB5B.js} +51 -23
- package/dist/{evolve-QNTFGV6Z.js → evolve-K7VE2CBX.js} +30 -20
- package/dist/{fleet-Q7UOMUSG.js → fleet-7XMJNQNF.js} +48 -38
- package/dist/{fleet-preflight-DDN536IT.js → fleet-preflight-AQNAH644.js} +3 -3
- package/dist/{init-WBB65ZHQ.js → init-JGNPAYXT.js} +41 -31
- package/dist/{memory-MD3O64RI.js → memory-4ALKDJ4Q.js} +32 -22
- package/dist/{models-BZU34YWD.js → models-ZMMLFJNN.js} +22 -19
- package/dist/{monitor-MEQA5C3I.js → monitor-2F3T5KHP.js} +55 -43
- package/dist/{orchestrator-CGFKEP27.js → orchestrator-ORHT43JB.js} +2507 -1896
- package/dist/{reset-L2FQEE3E.js → reset-NXGTYNUO.js} +4 -3
- package/dist/{run-IV4Q6RLN.js → run-RF4WJGMT.js} +51 -41
- package/dist/{share-S5BZQC5I.js → share-UT3W6E4M.js} +5 -4
- package/dist/{skills-LQEKRDTN.js → skills-PSACKC5Q.js} +2 -2
- package/dist/{skills-eval-3DC4HEWS.js → skills-eval-WJSI55RZ.js} +34 -24
- package/dist/{targets-C4SSGQOB.js → targets-PIIRAOYS.js} +23 -20
- package/dist/{terminal-lease-IT5JW2NR.js → terminal-lease-ULWXWNVY.js} +5 -4
- package/dist/{upgrade-7TT7SQ3G.js → upgrade-346TZ6AV.js} +18 -17
- package/dist/{usage-GV4PKT3M.js → usage-6KKXR32N.js} +34 -24
- package/dist/verifiers-4UUM6TEE.js +1214 -0
- package/dist/verify-X5HDROLA.js +25 -0
- package/dist/{wiki-generate-DQF6Z66B.js → wiki-generate-7STOCIFZ.js} +42 -31
- package/dist/worker/entry.js +33 -24
- package/docs/README.md +8 -7
- package/docs/acp.md +1 -1
- package/docs/alcf-provider.md +1 -1
- package/docs/architecture.md +2 -2
- package/docs/artifact-versions.md +1 -1
- package/docs/built-in-agents.md +1 -1
- package/docs/capacity-and-scheduling.md +1 -1
- package/docs/commands-and-modes.md +53 -21
- package/docs/config-knobs-audit.md +1 -2
- package/docs/configuration-and-targets.md +15 -1
- package/docs/context-engine.md +64 -12
- package/docs/context-working-set.md +194 -0
- package/docs/development-pipeline.md +1 -1
- package/docs/documentation-coverage.md +5 -5
- package/docs/documentation-guide.md +6 -5
- package/docs/environment-variables.md +2 -1
- package/docs/eval-runner.md +1 -1
- package/docs/evals-internal.md +14 -1
- package/docs/evidence-and-memory.md +74 -2
- package/docs/evolution.md +1 -1
- package/docs/exit-codes-and-output.md +1 -1
- package/docs/extensions-and-sharing.md +2 -2
- package/docs/fleet-dispatch.md +22 -7
- package/docs/glossary.md +21 -1
- package/docs/installation-and-lifecycle.md +6 -6
- package/docs/middleware-and-components.md +1 -1
- package/docs/model-catalog.md +7 -9
- package/docs/observability.md +4 -4
- package/docs/performance-methodology.md +2 -2
- package/docs/proactive-memory.md +1 -1
- package/docs/prompt-envelope-and-tools.md +4 -4
- package/docs/provider-adapter-cookbook.md +1 -1
- package/docs/release-cut-checklist.md +35 -35
- package/docs/safety-model.md +23 -4
- package/docs/scientific-validation.md +21 -3
- package/docs/session-lifecycle.md +3 -3
- package/docs/skills-marketplace.md +1 -1
- package/docs/tool-usage.md +79 -12
- package/docs/trace-store.md +1 -1
- package/docs/troubleshooting.md +1 -1
- package/docs/tui-design.md +2 -2
- package/docs/worker-dispatch-mechanics.md +11 -1
- package/package.json +8 -11
- package/skills/meta/clio-test/SKILL.md +20 -17
- package/skills/meta/clio-test/evals.md +3 -3
- package/skills/meta/clio-test/references/harness.md +35 -6
- package/skills/meta/clio-test/references/test-map.md +20 -10
- package/skills/registry.yaml +2 -2
- package/skills/skill-marketplace.json +1 -1
- package/src/cli/context-working-set.ts +513 -0
- package/src/cli/context.ts +8 -0
- package/src/cli/evidence.ts +20 -2
- package/src/cli/index.ts +4 -0
- package/src/cli/verifiers.ts +325 -0
- package/src/core/bash-exec.ts +39 -14
- package/src/core/bus-events.ts +19 -4
- package/src/core/config.ts +54 -0
- package/src/core/defaults.ts +50 -3
- package/src/core/git-commit-attribution.ts +46 -21
- package/src/core/verification-scripts.ts +6 -0
- package/src/domains/agents/builtins/verifier.md +3 -0
- package/src/domains/config/classify.ts +1 -0
- package/src/domains/config/keybindings.ts +3 -3
- package/src/domains/context/working-set/contract.ts +161 -0
- package/src/domains/context/working-set/defaults.ts +28 -0
- package/src/domains/context/working-set/engine.ts +203 -0
- package/src/domains/context/working-set/fold.ts +62 -0
- package/src/domains/context/working-set/horizon.ts +38 -0
- package/src/domains/context/working-set/marker.ts +103 -0
- package/src/domains/context/working-set/path-index.ts +436 -0
- package/src/domains/context/working-set/payload.ts +152 -0
- package/src/domains/context/working-set/policies/age-horizon.ts +55 -0
- package/src/domains/context/working-set/policies/index.ts +21 -0
- package/src/domains/context/working-set/policies/structural.ts +160 -0
- package/src/domains/context/working-set/project.ts +132 -0
- package/src/domains/context/working-set/protect.ts +109 -0
- package/src/domains/context/working-set/recall.ts +177 -0
- package/src/domains/context/working-set/replay/controls.ts +112 -0
- package/src/domains/context/working-set/replay/load-clio.ts +199 -0
- package/src/domains/context/working-set/replay/metrics.ts +185 -0
- package/src/domains/context/working-set/replay/reference-graph.ts +79 -0
- package/src/domains/context/working-set/replay/report.ts +139 -0
- package/src/domains/context/working-set/replay/runner.ts +325 -0
- package/src/domains/context/working-set/replay/synthetic.ts +422 -0
- package/src/domains/context/working-set/replay/trace.ts +21 -0
- package/src/domains/context/working-set/visible.ts +54 -0
- package/src/domains/evidence/build.ts +112 -45
- package/src/domains/evidence/eval.ts +24 -7
- package/src/domains/evidence/index.ts +53 -0
- package/src/domains/evidence/ordering.ts +12 -0
- package/src/domains/evidence/run-trust.ts +221 -0
- package/src/domains/evidence/store.ts +46 -6
- package/src/domains/evidence/trust-status.ts +854 -0
- package/src/domains/evidence/types.ts +26 -0
- package/src/domains/middleware/memory-intervention.ts +3 -0
- package/src/domains/middleware/stalled-turn.ts +165 -4
- package/src/domains/safety/autonomy.ts +1 -1
- package/src/domains/safety/default-path-policy.ts +8 -0
- package/src/domains/safety/finish-contract.ts +4 -3
- package/src/domains/safety/policy-engine.ts +48 -6
- package/src/domains/session/compaction/compact.ts +23 -1
- package/src/domains/session/compaction/cut-point.ts +2 -0
- package/src/domains/session/compaction/tokens.ts +16 -1
- package/src/domains/session/context-ledger.ts +2 -0
- package/src/domains/session/entries.ts +107 -1
- package/src/domains/session/manager.ts +9 -2
- package/src/domains/session/migrations/index.ts +22 -3
- package/src/engine/acp/server.ts +3 -0
- package/src/engine/agent.ts +18 -1
- package/src/engine/session.ts +9 -3
- package/src/entry/orchestrator.ts +16 -4
- package/src/interactive/chat-loop-messages.ts +18 -6
- package/src/interactive/chat-panel.ts +571 -244
- package/src/interactive/chat-renderer.ts +79 -39
- package/src/interactive/context-meter.ts +10 -0
- package/src/interactive/context-overlay.ts +81 -6
- package/src/interactive/context-recall-command.ts +110 -0
- package/src/interactive/editor-submit.ts +26 -1
- package/src/interactive/footer/widgets.ts +22 -20
- package/src/interactive/footer-panel.ts +6 -1
- package/src/interactive/interactive-application.ts +2 -0
- package/src/interactive/interactive-event-projection.ts +12 -0
- package/src/interactive/interactive-slash-runtime.ts +49 -8
- package/src/interactive/model-session-replay.ts +21 -0
- package/src/interactive/overlay-general-openers.ts +6 -0
- package/src/interactive/overlay-session-lifecycle.ts +8 -4
- package/src/interactive/overlays/ask-user.ts +146 -24
- package/src/interactive/renderers/tool-execution.ts +167 -56
- package/src/interactive/session-transcript.ts +2 -2
- package/src/interactive/slash-commands.ts +29 -2
- package/src/interactive/status/index.ts +12 -1
- package/src/interactive/status/reasoning.ts +87 -0
- package/src/interactive/status/summary.ts +13 -2
- package/src/interactive/transcript-detail.ts +120 -0
- package/src/interactive/turn-context.ts +238 -88
- package/src/interactive/turn-middleware.ts +6 -6
- package/src/tools/agent-tools.ts +11 -4
- package/src/tools/bash.ts +144 -82
- package/src/tools/builtin-tool-catalog.ts +18 -6
- package/src/tools/context/index.ts +105 -3
- package/src/tools/context/surface.ts +3 -2
- package/src/tools/core-bootstrap.ts +21 -0
- package/src/tools/dispatch-runner.ts +9 -7
- package/src/tools/monitor.ts +28 -20
- package/src/tools/presentation.ts +107 -0
- package/src/tools/registry.ts +65 -7
- package/src/tools/result-disposition.ts +550 -0
- package/src/tools/result-shaping.ts +262 -19
- package/src/tools/safe-exec.ts +2 -0
- package/src/tools/verify/authoring.ts +1119 -0
- package/src/tools/verify/catalog.ts +346 -0
- package/src/tools/verify/index.ts +13 -3
- package/src/tools/verify/scripts.ts +135 -37
- package/src/tools/verify/surface.ts +9 -5
- package/src/tools/worker-evidence.ts +35 -12
- package/dist/chunk-MNA4JGU4.js +0 -255
- package/dist/chunk-SRF2PJNW.js +0 -184
- package/dist/chunk-T6YILFSB.js +0 -80
- package/dist/chunk-VAKQQHWR.js +0 -434
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { createRequire as __clioCreateRequire } from "node:module"; const require = __clioCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
clampTimerDelayMs
|
|
4
|
+
} from "./chunk-FQ4SKYE4.js";
|
|
2
5
|
import {
|
|
3
6
|
clioStateDir
|
|
4
7
|
} from "./chunk-BNAZZHFG.js";
|
|
@@ -95,7 +98,17 @@ function attributeCommitMessage(originalMessage, evidence, enabled = true) {
|
|
|
95
98
|
// src/core/git-commit-attribution.ts
|
|
96
99
|
init_esm_shims();
|
|
97
100
|
import { execFileSync } from "node:child_process";
|
|
98
|
-
import {
|
|
101
|
+
import {
|
|
102
|
+
accessSync,
|
|
103
|
+
chmodSync,
|
|
104
|
+
existsSync,
|
|
105
|
+
constants as fsConstants,
|
|
106
|
+
mkdirSync,
|
|
107
|
+
readFileSync,
|
|
108
|
+
renameSync,
|
|
109
|
+
rmSync,
|
|
110
|
+
writeFileSync
|
|
111
|
+
} from "node:fs";
|
|
99
112
|
import { join, resolve } from "node:path";
|
|
100
113
|
var CLIO_GIT_COMMITS_ENABLED_ENV = "CLIO_CODER_GIT_COMMITS_ENABLED";
|
|
101
114
|
var ASSISTED_ENV = "CLIO_CODER_COMMIT_ASSISTED";
|
|
@@ -200,27 +213,29 @@ case "$base_count" in
|
|
|
200
213
|
;;
|
|
201
214
|
esac
|
|
202
215
|
|
|
203
|
-
#
|
|
204
|
-
# environment
|
|
205
|
-
#
|
|
206
|
-
|
|
207
|
-
|
|
216
|
+
# Resolve the current repository's default hooks directory before interpreting
|
|
217
|
+
# the environment prepared for the originating repository. A command may have
|
|
218
|
+
# moved into a different repository in between; an explicit default path is
|
|
219
|
+
# composable only while it still names this same repository's default.
|
|
220
|
+
common_dir=$(git rev-parse --git-common-dir 2>/dev/null || true)
|
|
221
|
+
common_dir_absolute=$(cd "$common_dir" 2>/dev/null && pwd -P || true)
|
|
222
|
+
case "$common_dir_absolute" in
|
|
223
|
+
'') default_hooks_directory=; default_hook= ;;
|
|
224
|
+
*) default_hooks_directory=$common_dir_absolute/hooks; default_hook=$default_hooks_directory/$hook_name ;;
|
|
225
|
+
esac
|
|
226
|
+
|
|
227
|
+
if git config --get core.hooksPath >/dev/null 2>&1 &&
|
|
228
|
+
[ "$${DEFAULT_HOOKS_EQUIVALENT_ENV}" != "$default_hooks_directory" ]; then
|
|
229
|
+
custom_hooks=$(git config --path --get core.hooksPath 2>/dev/null || true)
|
|
208
230
|
case "$custom_hooks" in
|
|
209
231
|
'') ;;
|
|
210
232
|
/*) custom_hook=$custom_hooks/$hook_name ;;
|
|
211
233
|
*) custom_hook=$PWD/$custom_hooks/$hook_name ;;
|
|
212
234
|
esac
|
|
213
235
|
if [ -n "$custom_hooks" ] && [ -x "$custom_hook" ]; then exec "$custom_hook" "$@"; fi
|
|
214
|
-
|
|
236
|
+
exit 0
|
|
215
237
|
fi
|
|
216
238
|
|
|
217
|
-
common_dir=$(git rev-parse --git-common-dir 2>/dev/null || true)
|
|
218
|
-
case "$common_dir" in
|
|
219
|
-
'') default_hook= ;;
|
|
220
|
-
/*) default_hook=$common_dir/hooks/$hook_name ;;
|
|
221
|
-
*) default_hook=$PWD/$common_dir/hooks/$hook_name ;;
|
|
222
|
-
esac
|
|
223
|
-
|
|
224
239
|
if [ "$hook_name" != 'prepare-commit-msg' ]; then
|
|
225
240
|
if [ -n "$default_hook" ] && [ -x "$default_hook" ]; then exec "$default_hook" "$@"; fi
|
|
226
241
|
exit 0
|
|
@@ -284,9 +299,21 @@ function installManagedHook(directory, name) {
|
|
|
284
299
|
rmSync(temporary, { force: true });
|
|
285
300
|
}
|
|
286
301
|
}
|
|
302
|
+
function managedHooksDirectoryIsIntact(directory) {
|
|
303
|
+
try {
|
|
304
|
+
for (const name of MANAGED_HOOK_NAMES) {
|
|
305
|
+
const hook = join(directory, name);
|
|
306
|
+
if (readFileSync(hook, "utf8") !== MANAGED_HOOK_SCRIPT) return false;
|
|
307
|
+
accessSync(hook, fsConstants.X_OK);
|
|
308
|
+
}
|
|
309
|
+
return true;
|
|
310
|
+
} catch {
|
|
311
|
+
return false;
|
|
312
|
+
}
|
|
313
|
+
}
|
|
287
314
|
function managedHooksDirectory() {
|
|
288
315
|
const directory = join(clioStateDir(), "git-hooks", `v${MANAGED_HOOK_VERSION}`);
|
|
289
|
-
if (installedHooksDirectory === directory &&
|
|
316
|
+
if (installedHooksDirectory === directory && managedHooksDirectoryIsIntact(directory)) return directory;
|
|
290
317
|
mkdirSync(directory, { recursive: true, mode: 448 });
|
|
291
318
|
for (const name of MANAGED_HOOK_NAMES) installManagedHook(directory, name);
|
|
292
319
|
installedHooksDirectory = directory;
|
|
@@ -302,13 +329,13 @@ function gitEnvironmentFingerprint(env) {
|
|
|
302
329
|
function probeRepositoryUncached(cwd, env) {
|
|
303
330
|
if (gitOutput(cwd, env, ["rev-parse", "--is-inside-work-tree"]) !== "true") return { kind: "outside" };
|
|
304
331
|
const customHooksPath = gitOutput(cwd, env, ["config", "--path", "--get", "core.hooksPath"]);
|
|
305
|
-
if (customHooksPath === null) return { kind: "default",
|
|
332
|
+
if (customHooksPath === null) return { kind: "default", declaredDefaultHooksPath: null };
|
|
306
333
|
const commonDirectory = gitOutput(cwd, env, ["rev-parse", "--git-common-dir"]);
|
|
307
334
|
const defaultHooksPath = commonDirectory === null ? null : resolve(cwd, commonDirectory, "hooks");
|
|
308
335
|
if (customHooksPath.length === 0 || resolve(cwd, customHooksPath) !== defaultHooksPath) {
|
|
309
336
|
return { kind: "custom", hooksPath: customHooksPath };
|
|
310
337
|
}
|
|
311
|
-
return { kind: "default",
|
|
338
|
+
return { kind: "default", declaredDefaultHooksPath: defaultHooksPath };
|
|
312
339
|
}
|
|
313
340
|
function probeRepository(cwd, env, now = Date.now()) {
|
|
314
341
|
const key = `${cwd}\0${gitEnvironmentFingerprint(env)}`;
|
|
@@ -346,7 +373,9 @@ function withManagedGitCommitAttributionEnvironment(source, options = {}) {
|
|
|
346
373
|
diagnostic: boundedDiagnostic(`core.hooksPath is set to '${probe.hooksPath}'; Clio commit attribution skipped`)
|
|
347
374
|
};
|
|
348
375
|
}
|
|
349
|
-
if (probe.
|
|
376
|
+
if (probe.declaredDefaultHooksPath !== null) {
|
|
377
|
+
env[DEFAULT_HOOKS_EQUIVALENT_ENV] = probe.declaredDefaultHooksPath;
|
|
378
|
+
}
|
|
350
379
|
let hooksDirectory;
|
|
351
380
|
try {
|
|
352
381
|
hooksDirectory = managedHooksDirectory();
|
|
@@ -364,11 +393,176 @@ function withManagedGitCommitAttributionEnvironment(source, options = {}) {
|
|
|
364
393
|
return { env, diagnostic: null };
|
|
365
394
|
}
|
|
366
395
|
|
|
396
|
+
// src/core/safe-exec.ts
|
|
397
|
+
init_esm_shims();
|
|
398
|
+
import { spawn } from "node:child_process";
|
|
399
|
+
import path from "node:path";
|
|
400
|
+
import { performance } from "node:perf_hooks";
|
|
401
|
+
var SAFE_EXEC_DEFAULT_TIMEOUT_MS = 12e4;
|
|
402
|
+
var SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES = 6e5;
|
|
403
|
+
var ENV_ALLOWLIST = [
|
|
404
|
+
"PATH",
|
|
405
|
+
"HOME",
|
|
406
|
+
"USER",
|
|
407
|
+
"LOGNAME",
|
|
408
|
+
"LANG",
|
|
409
|
+
"LC_ALL",
|
|
410
|
+
"TMPDIR",
|
|
411
|
+
"TEMP",
|
|
412
|
+
"TMP",
|
|
413
|
+
"CI",
|
|
414
|
+
"NO_COLOR"
|
|
415
|
+
];
|
|
416
|
+
function buildSafeToolEnv(extra = {}) {
|
|
417
|
+
const env = {};
|
|
418
|
+
for (const key of ENV_ALLOWLIST) {
|
|
419
|
+
const value = process.env[key];
|
|
420
|
+
if (value !== void 0) env[key] = value;
|
|
421
|
+
}
|
|
422
|
+
for (const [key, value] of Object.entries(extra)) {
|
|
423
|
+
if (!/^[A-Z_][A-Z0-9_]*$/i.test(key)) continue;
|
|
424
|
+
env[key] = value;
|
|
425
|
+
}
|
|
426
|
+
env.AI_AGENT = AI_AGENT_NAME;
|
|
427
|
+
return env;
|
|
428
|
+
}
|
|
429
|
+
function resolveSafeCwd(cwd, workspaceRoot = process.cwd()) {
|
|
430
|
+
const root = path.resolve(workspaceRoot);
|
|
431
|
+
const resolved = cwd === void 0 ? root : path.isAbsolute(cwd) ? path.resolve(cwd) : path.resolve(root, cwd);
|
|
432
|
+
const rel = path.relative(root, resolved);
|
|
433
|
+
if (rel === "" || !rel.startsWith("..") && !path.isAbsolute(rel)) return resolved;
|
|
434
|
+
throw new Error(`cwd escapes workspace root: ${resolved}`);
|
|
435
|
+
}
|
|
436
|
+
function runCommandVector(file, args, options = {}) {
|
|
437
|
+
return new Promise((resolve2) => {
|
|
438
|
+
const startedAt = performance.now();
|
|
439
|
+
const cwd = resolveSafeCwd(options.cwd, options.workspaceRoot);
|
|
440
|
+
const timeoutMs = clampTimerDelayMs(options.timeoutMs ?? SAFE_EXEC_DEFAULT_TIMEOUT_MS);
|
|
441
|
+
const maxOutputBytes = options.maxOutputBytes ?? SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES;
|
|
442
|
+
const attribution = withManagedGitCommitAttributionEnvironment(buildSafeToolEnv(options.env), {
|
|
443
|
+
cwd,
|
|
444
|
+
enabled: gitCommitAttributionEnabled(process.env)
|
|
445
|
+
});
|
|
446
|
+
reportCommitAttributionDiagnostic(attribution.diagnostic);
|
|
447
|
+
let aborted = false;
|
|
448
|
+
let timedOut = false;
|
|
449
|
+
let outputCapped = false;
|
|
450
|
+
let outputBytes = 0;
|
|
451
|
+
let stdout = "";
|
|
452
|
+
let stderr = "";
|
|
453
|
+
let settled = false;
|
|
454
|
+
let killSent = false;
|
|
455
|
+
let timeoutId = null;
|
|
456
|
+
let killGraceTimer = null;
|
|
457
|
+
const child = spawn(file, [...args], {
|
|
458
|
+
cwd,
|
|
459
|
+
env: attribution.env,
|
|
460
|
+
detached: process.platform !== "win32",
|
|
461
|
+
stdio: ["ignore", "pipe", "pipe"]
|
|
462
|
+
});
|
|
463
|
+
const clearKillGraceTimer = () => {
|
|
464
|
+
if (killGraceTimer) clearTimeout(killGraceTimer);
|
|
465
|
+
killGraceTimer = null;
|
|
466
|
+
};
|
|
467
|
+
const sendSignal = (signalName) => {
|
|
468
|
+
const pid = child.pid;
|
|
469
|
+
if (pid && process.platform !== "win32") {
|
|
470
|
+
try {
|
|
471
|
+
process.kill(-pid, signalName);
|
|
472
|
+
return;
|
|
473
|
+
} catch {
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
child.kill(signalName);
|
|
477
|
+
};
|
|
478
|
+
const killChild = () => {
|
|
479
|
+
if (killSent) return;
|
|
480
|
+
killSent = true;
|
|
481
|
+
sendSignal("SIGTERM");
|
|
482
|
+
killGraceTimer = setTimeout(() => sendSignal("SIGKILL"), 3e3);
|
|
483
|
+
};
|
|
484
|
+
const onAbort = () => {
|
|
485
|
+
aborted = true;
|
|
486
|
+
killChild();
|
|
487
|
+
};
|
|
488
|
+
if (timeoutMs > 0) {
|
|
489
|
+
timeoutId = setTimeout(() => {
|
|
490
|
+
timedOut = true;
|
|
491
|
+
killChild();
|
|
492
|
+
}, timeoutMs);
|
|
493
|
+
}
|
|
494
|
+
if (options.signal?.aborted) onAbort();
|
|
495
|
+
else options.signal?.addEventListener("abort", onAbort, { once: true });
|
|
496
|
+
const appendChunk = (target, chunk) => {
|
|
497
|
+
outputBytes += chunk.byteLength;
|
|
498
|
+
if (outputBytes > maxOutputBytes) {
|
|
499
|
+
outputCapped = true;
|
|
500
|
+
killChild();
|
|
501
|
+
return;
|
|
502
|
+
}
|
|
503
|
+
if (target === "stdout") stdout += chunk.toString("utf8");
|
|
504
|
+
else stderr += chunk.toString("utf8");
|
|
505
|
+
};
|
|
506
|
+
child.stdout?.on("data", (chunk) => appendChunk("stdout", chunk));
|
|
507
|
+
child.stderr?.on("data", (chunk) => appendChunk("stderr", chunk));
|
|
508
|
+
child.on("error", (error) => {
|
|
509
|
+
if (settled) return;
|
|
510
|
+
settled = true;
|
|
511
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
512
|
+
clearKillGraceTimer();
|
|
513
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
514
|
+
resolve2({
|
|
515
|
+
file,
|
|
516
|
+
args: [...args],
|
|
517
|
+
cwd,
|
|
518
|
+
stdout,
|
|
519
|
+
stderr: stderr.length > 0 ? stderr : error.message,
|
|
520
|
+
exitCode: null,
|
|
521
|
+
signal: null,
|
|
522
|
+
aborted,
|
|
523
|
+
timedOut,
|
|
524
|
+
outputCapped,
|
|
525
|
+
durationMs: Math.round(performance.now() - startedAt)
|
|
526
|
+
});
|
|
527
|
+
});
|
|
528
|
+
child.on("close", (code, signalName) => {
|
|
529
|
+
if (settled) return;
|
|
530
|
+
settled = true;
|
|
531
|
+
if (timeoutId) clearTimeout(timeoutId);
|
|
532
|
+
clearKillGraceTimer();
|
|
533
|
+
options.signal?.removeEventListener("abort", onAbort);
|
|
534
|
+
resolve2({
|
|
535
|
+
file,
|
|
536
|
+
args: [...args],
|
|
537
|
+
cwd,
|
|
538
|
+
stdout,
|
|
539
|
+
stderr,
|
|
540
|
+
exitCode: code,
|
|
541
|
+
signal: signalName,
|
|
542
|
+
aborted,
|
|
543
|
+
timedOut,
|
|
544
|
+
outputCapped,
|
|
545
|
+
durationMs: Math.round(performance.now() - startedAt)
|
|
546
|
+
});
|
|
547
|
+
});
|
|
548
|
+
});
|
|
549
|
+
}
|
|
550
|
+
function combineSafeOutput(result) {
|
|
551
|
+
const { stdout, stderr } = result;
|
|
552
|
+
return stderr.length > 0 ? `${stdout}${stdout.endsWith("\n") || stdout.length === 0 ? "" : "\n"}${stderr}` : stdout;
|
|
553
|
+
}
|
|
554
|
+
|
|
367
555
|
export {
|
|
368
556
|
attributeCommitMessage,
|
|
369
557
|
reportCommitAttributionDiagnostic,
|
|
370
558
|
setGitCommitAttributionEnabled,
|
|
371
559
|
gitCommitAttributionEnabled,
|
|
372
|
-
withManagedGitCommitAttributionEnvironment
|
|
560
|
+
withManagedGitCommitAttributionEnvironment,
|
|
561
|
+
SAFE_EXEC_DEFAULT_TIMEOUT_MS,
|
|
562
|
+
SAFE_EXEC_DEFAULT_MAX_OUTPUT_BYTES,
|
|
563
|
+
buildSafeToolEnv,
|
|
564
|
+
resolveSafeCwd,
|
|
565
|
+
runCommandVector,
|
|
566
|
+
combineSafeOutput
|
|
373
567
|
};
|
|
374
|
-
//# sourceMappingURL=chunk-
|
|
568
|
+
//# sourceMappingURL=chunk-VEZEGCGW.js.map
|