skyloom 1.4.0 → 1.4.2

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skyloom",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "天空织机 Skyloom — 6 weather-themed AI agents: Fog, Rain, Frost, Snow, Dew, Fair",
5
5
  "preferGlobal": true,
6
6
  "type": "commonjs",
package/src/cli/main.ts CHANGED
@@ -377,22 +377,29 @@ function shouldAutoContinue(text: string): boolean {
377
377
  async function main(): Promise<void> {
378
378
  const args = process.argv.slice(2);
379
379
 
380
- // If no args or just "chat", start interactive chat
381
- if (args.length === 0 || args[0] === 'chat' || (args.length === 1 && !args[0].startsWith('-') && !['task', 'web', 'config', 'init', 'version'].includes(args[0]))) {
382
- // Check if first arg is an agent name
383
- const knownAgents = new Set(['fog', 'rain', 'frost', 'snow', 'dew', 'fair']);
384
- let agent = 'fog';
385
- let model: string | undefined;
380
+ // `sky` with no args = start chat directly (fastest path)
381
+ if (args.length === 0) {
382
+ await interactiveChat('fog');
383
+ return;
384
+ }
386
385
 
387
- for (let i = 0; i < args.length; i++) {
388
- if (knownAgents.has(args[i])) {
389
- agent = args[i];
390
- } else if (args[i] === '-m' || args[i] === '--model') {
386
+ // `sky <agent>` or `sky <agent> -m <model>` chat with specific agent
387
+ const knownAgents = new Set(['fog', 'rain', 'frost', 'snow', 'dew', 'fair']);
388
+ if (knownAgents.has(args[0])) {
389
+ let model: string | undefined;
390
+ for (let i = 1; i < args.length; i++) {
391
+ if ((args[i] === '-m' || args[i] === '--model') && i + 1 < args.length) {
391
392
  model = args[++i];
392
393
  }
393
394
  }
395
+ await interactiveChat(args[0], model);
396
+ return;
397
+ }
394
398
 
395
- await interactiveChat(agent, model);
399
+ // `sky <message>` — anything not a known subcommand → fast chat
400
+ const knownCommands = ['chat', 'task', 'web', 'config', 'init', 'version', 'mcp', 'help'];
401
+ if (!knownCommands.includes(args[0]) && !args[0].startsWith('-')) {
402
+ await interactiveChat('fog');
396
403
  return;
397
404
  }
398
405
 
package/src/core/agent.ts CHANGED
@@ -729,13 +729,14 @@ export class BaseAgent {
729
729
  try {
730
730
  if (onStatus) onStatus('thinking...');
731
731
  const response = await this.llmLoop({ onStatus });
732
- this.memory.addMessage('assistant', response.content, {
733
- toolCalls: response.toolCalls,
734
- reasoningContent: response.reasoningContent,
732
+ const content = response?.content || '(no response)';
733
+ this.memory.addMessage('assistant', content, {
734
+ toolCalls: response?.toolCalls || [],
735
+ reasoningContent: response?.reasoningContent,
735
736
  });
736
737
  await this.setState(AgentState.IDLE);
737
738
  this.maybeExtractFacts();
738
- return response.content;
739
+ return content;
739
740
  } catch (e) {
740
741
  await this.setState(AgentState.ERROR);
741
742
  this.popLastUserMessage();
@@ -69,9 +69,8 @@ export class Logger {
69
69
  return value;
70
70
  });
71
71
 
72
- // Output to stderr for logs, stdout for normal output
73
- const output = level >= LogLevel.WARN ? console.error : console.log;
74
- output(line);
72
+ // Write all logs to stderr to keep stdout clean for chat/TUI
73
+ process.stderr.write(line + "\n");
75
74
  }
76
75
 
77
76
  debug(msg: string, extra?: Record<string, unknown>) {
@@ -100,7 +99,7 @@ export class Logger {
100
99
  */
101
100
  const loggers = new Map<string, Logger>();
102
101
  let requestId: string | null = null;
103
- let defaultLogLevel = LogLevel.INFO;
102
+ let defaultLogLevel = LogLevel.WARN; // Only warnings+errors by default
104
103
 
105
104
  /**
106
105
  * Get or create a logger for a component
@@ -276,7 +276,9 @@ export class Memory {
276
276
  private dbRun(sql: string, params?: any[]): void {
277
277
  if (!this.db) return;
278
278
  try {
279
- this.db.run(sql, params);
279
+ // Sql.js rejects `undefined` in bind arrays; normalize to `null`
280
+ const safe = params ? params.map((v) => v === undefined ? null : v) : undefined;
281
+ this.db.run(sql, safe);
280
282
  } catch (err) {
281
283
  logger.warn('db_run_failed', { sql: sql.slice(0, 80), error: String(err) });
282
284
  }