cclaw-cli 0.5.9 → 0.5.10
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/content/hooks.js +14 -4
- package/package.json +1 -1
package/dist/content/hooks.js
CHANGED
|
@@ -786,8 +786,15 @@ export default function cclawPlugin(ctx) {
|
|
|
786
786
|
return parts.join("\\n");
|
|
787
787
|
}
|
|
788
788
|
|
|
789
|
-
|
|
790
|
-
|
|
789
|
+
let bootstrapCache = "";
|
|
790
|
+
|
|
791
|
+
function refreshBootstrapCache() {
|
|
792
|
+
bootstrapCache = buildBootstrap();
|
|
793
|
+
}
|
|
794
|
+
|
|
795
|
+
function getBootstrap() {
|
|
796
|
+
if (!bootstrapCache) refreshBootstrapCache();
|
|
797
|
+
return bootstrapCache;
|
|
791
798
|
}
|
|
792
799
|
|
|
793
800
|
async function runHookScript(scriptFileName, payload = {}) {
|
|
@@ -843,7 +850,10 @@ export default function cclawPlugin(ctx) {
|
|
|
843
850
|
eventType === "session.compacted" ||
|
|
844
851
|
eventType === "session.cleared"
|
|
845
852
|
) {
|
|
846
|
-
|
|
853
|
+
// Avoid writing directly to stdout in lifecycle hooks because it can
|
|
854
|
+
// interfere with OpenCode TUI rendering. Bootstrap is injected via
|
|
855
|
+
// the system transform hook instead.
|
|
856
|
+
refreshBootstrapCache();
|
|
847
857
|
}
|
|
848
858
|
if (eventType === "session.idle") {
|
|
849
859
|
await runHookScript("stop-checkpoint.sh", { loop_count: 0 });
|
|
@@ -868,7 +878,7 @@ export default function cclawPlugin(ctx) {
|
|
|
868
878
|
await runHookScript("context-monitor.sh", payload);
|
|
869
879
|
},
|
|
870
880
|
"experimental.chat.system.transform": (payload) => {
|
|
871
|
-
const bootstrap =
|
|
881
|
+
const bootstrap = getBootstrap();
|
|
872
882
|
if (typeof payload === "string") {
|
|
873
883
|
return payload.includes("cclaw loaded.") ? payload : \`\${payload}\\n\\n\${bootstrap}\`;
|
|
874
884
|
}
|