jarvis-agent-factory 3.22.0 → 3.22.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": "jarvis-agent-factory",
3
- "version": "3.22.0",
3
+ "version": "3.22.2",
4
4
  "description": "Jarvis Agent Factory CLI — 跨平台多智能体 AI 编程助手配置安装器 | Multi-agent AI coding assistant config installer for Claude Code / OpenCode / Codex",
5
5
  "keywords": [
6
6
  "jarvis",
package/src/engine/db.js CHANGED
@@ -44,21 +44,75 @@ function initSchema(db) {
44
44
  effort TEXT NOT NULL DEFAULT 'high',
45
45
  updated_at TEXT NOT NULL
46
46
  );
47
- -- Migration: rename old single-row pipeline table if exists
48
47
  `);
49
48
  try { db.exec("ALTER TABLE agent_models ADD COLUMN effort TEXT NOT NULL DEFAULT 'high'"); } catch {}
50
- // Migration from old single-row pipeline: add session_id if missing
51
- try { db.exec("ALTER TABLE pipeline ADD COLUMN session_id TEXT"); } catch {}
52
- try {
53
- const old = db.prepare('SELECT id, project, current_gate, started_at, updated_at FROM pipeline WHERE session_id IS NULL').all();
54
- for (const r of old) {
55
- db.prepare('INSERT OR REPLACE INTO pipeline (session_id, project, current_gate, started_at, updated_at) VALUES (?, ?, ?, ?, ?)').run('legacy', r.project, r.current_gate, r.started_at, r.updated_at);
49
+
50
+ // ---- 迁移:修复旧 pipeline CHECK(id=1) 约束 ----
51
+ const pipeSchema = db.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='pipeline'").get();
52
+ if (pipeSchema && /CHECK\s*\(\s*id\s*=\s*1\s*\)/i.test(pipeSchema.sql)) {
53
+ // 旧单行表有 CHECK(id=1) 约束,需重建
54
+ db.exec('BEGIN');
55
+ try {
56
+ // 备份旧数据(旧表可能有 id, project, current_gate, mode, started_at, updated_at, session_id, pipeline_type)
57
+ const oldRows = db.prepare('SELECT * FROM pipeline').all();
58
+ db.exec('DROP TABLE IF EXISTS pipeline');
59
+ db.exec(`
60
+ CREATE TABLE pipeline (
61
+ session_id TEXT PRIMARY KEY,
62
+ project TEXT NOT NULL,
63
+ current_gate TEXT NOT NULL DEFAULT 'Gate A',
64
+ pipeline_type TEXT NOT NULL DEFAULT 'full',
65
+ started_at TEXT NOT NULL,
66
+ updated_at TEXT NOT NULL
67
+ )
68
+ `);
69
+ for (const r of oldRows) {
70
+ const sid = r.session_id || 'legacy';
71
+ const pt = r.pipeline_type || 'full';
72
+ db.prepare(`INSERT OR REPLACE INTO pipeline (session_id, project, current_gate, pipeline_type, started_at, updated_at)
73
+ VALUES (?, ?, ?, ?, ?, ?)`).run(sid, r.project || 'jarvis', r.current_gate || 'Gate A', pt, r.started_at || new Date().toISOString(), r.updated_at || new Date().toISOString());
74
+ }
75
+ db.exec('COMMIT');
76
+ console.log(' ✓ pipeline 表已从旧 CHECK(id=1) 模式迁移为多会话模式');
77
+ } catch (e) {
78
+ db.exec('ROLLBACK');
79
+ console.error(' ✗ pipeline 迁移失败:', e.message);
80
+ }
81
+ }
82
+
83
+ // ---- 迁移:修复旧 checkpoints 表 UNIQUE(gate) → UNIQUE(session_id, gate) ----
84
+ const cpSchema = db.prepare("SELECT sql FROM sqlite_master WHERE type='table' AND name='checkpoints'").get();
85
+ if (cpSchema && !/session_id.*gate/i.test(cpSchema.sql)) {
86
+ // 旧表只有 UNIQUE(gate),缺少 session_id 列或多列唯一约束
87
+ db.exec('BEGIN');
88
+ try {
89
+ const oldRows = db.prepare('SELECT * FROM checkpoints').all();
90
+ db.exec('DROP TABLE IF EXISTS checkpoints');
91
+ db.exec(`
92
+ CREATE TABLE checkpoints (
93
+ id INTEGER PRIMARY KEY AUTOINCREMENT,
94
+ session_id TEXT NOT NULL,
95
+ gate TEXT NOT NULL,
96
+ passed_at TEXT NOT NULL,
97
+ advance_to TEXT,
98
+ UNIQUE(session_id, gate)
99
+ )
100
+ `);
101
+ for (const r of oldRows) {
102
+ const sid = r.session_id || 'legacy';
103
+ db.prepare('INSERT OR REPLACE INTO checkpoints (session_id, gate, passed_at, advance_to) VALUES (?, ?, ?, ?)')
104
+ .run(sid, r.gate, r.passed_at || new Date().toISOString(), r.advance_to || null);
105
+ }
106
+ db.exec('COMMIT');
107
+ console.log(' ✓ checkpoints 表已迁移为 session_id+gate 联合唯一约束');
108
+ } catch (e) {
109
+ db.exec('ROLLBACK');
110
+ console.error(' ✗ checkpoints 迁移失败:', e.message);
56
111
  }
57
- } catch {}
58
- // Migrate: add status column to sessions if missing
112
+ }
113
+
114
+ // ---- 旧列迁移(向后兼容) ----
59
115
  try { db.exec("ALTER TABLE sessions ADD COLUMN status TEXT DEFAULT 'active'"); } catch {}
60
- // Migrate: add pipeline_type column to pipeline if missing
61
- try { db.exec("ALTER TABLE pipeline ADD COLUMN pipeline_type TEXT DEFAULT 'full'"); } catch {}
62
116
  }
63
117
 
64
118
  // ---- Pipeline (per-session) ----