@yeaft/webchat-agent 0.1.247 → 0.1.248

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/conversation.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import ctx from './context.js';
2
- import { query, Stream } from './sdk/index.js';
2
+ import { query } from './sdk/index.js';
3
3
  import { loadSessionHistory } from './history.js';
4
4
  import { startClaudeQuery } from './claude.js';
5
5
  import { crewSessions, loadCrewIndex } from './crew.js';
@@ -23,8 +23,9 @@ function prestartClaude(conversationId, workDir, resumeSessionId) {
23
23
 
24
24
  /**
25
25
  * Preload slash commands from Claude CLI (fire-and-forget).
26
- * Spawns a minimal CLI process to capture the system init message,
27
- * then aborts immediately (no API tokens consumed — init is local).
26
+ * Spawns a minimal CLI process with a cheap built-in command (/cost)
27
+ * to trigger the system init message, captures slash_commands,
28
+ * then aborts immediately (no API tokens consumed).
28
29
  *
29
30
  * @param {string} [workDir] - Project directory (default: agent workDir)
30
31
  * @param {string} [targetId] - conversationId to key the update to
@@ -34,9 +35,11 @@ export async function preloadSlashCommands(workDir, targetId = '__preload__') {
34
35
  const effectiveWorkDir = workDir || ctx.CONFIG.workDir;
35
36
  try {
36
37
  const abortController = new AbortController();
37
- const inputStream = new Stream();
38
+ // Use --print with a cheap built-in command to trigger system init.
39
+ // In stream-json mode, Claude CLI won't emit init until a user message arrives,
40
+ // so we use string prompt mode instead which triggers init immediately.
38
41
  const claudeQuery = query({
39
- prompt: inputStream,
42
+ prompt: '/cost',
40
43
  options: {
41
44
  cwd: effectiveWorkDir,
42
45
  permissionMode: 'bypassPermissions',
package/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'dotenv/config';
2
2
  import { platform, homedir } from 'os';
3
- import { existsSync, readFileSync, writeFileSync, mkdirSync, cpSync } from 'fs';
3
+ import { existsSync, readFileSync, writeFileSync, mkdirSync, cpSync, chmodSync, readdirSync } from 'fs';
4
4
  import { join, dirname } from 'path';
5
5
  import { exec } from 'child_process';
6
6
  import { promisify } from 'util';
@@ -217,10 +217,22 @@ async function ensureYeaftSkills() {
217
217
  writeFileSync(knownFile, JSON.stringify(known, null, 2));
218
218
  }
219
219
 
220
+ // --- Layer 2.5: Ensure hook scripts are executable (git clone may lose +x on some OS) ---
221
+ const fixHookPermissions = (dir) => {
222
+ const hooksDir = join(dir, 'hooks');
223
+ if (existsSync(hooksDir)) {
224
+ for (const f of readdirSync(hooksDir)) {
225
+ try { chmodSync(join(hooksDir, f), 0o755); } catch { /* ignore */ }
226
+ }
227
+ }
228
+ };
229
+ fixHookPermissions(installDir);
230
+
220
231
  // --- Layer 3: Copy to plugin cache (on first install or after update) ---
221
232
  if (!existsSync(cacheDir) || needsCacheUpdate) {
222
233
  mkdirSync(cacheDir, { recursive: true });
223
234
  cpSync(installDir, cacheDir, { recursive: true });
235
+ fixHookPermissions(cacheDir);
224
236
  console.log(`[Startup] yeaft-skills ${needsCacheUpdate ? 'updated in' : 'copied to'} plugin cache`);
225
237
  }
226
238
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@yeaft/webchat-agent",
3
- "version": "0.1.247",
3
+ "version": "0.1.248",
4
4
  "description": "Remote agent for Yeaft WebChat — connects worker machines to the central server",
5
5
  "main": "index.js",
6
6
  "type": "module",