@optima-chat/dev-skills 0.7.22 → 0.7.24

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.
@@ -7,7 +7,7 @@ function parseArgs(args: string[]): { email: string; plan: string; months: numbe
7
7
  console.log(`Usage: optima-grant-subscription <email> [options]
8
8
 
9
9
  Options:
10
- --plan <id> Plan: free, pro, enterprise (default: enterprise)
10
+ --plan <id> Plan: trial, starter, pro, enterprise (default: pro)
11
11
  --months <n> Duration in months (default: 1)
12
12
  --env <env> Environment: stage, prod (default: stage)
13
13
  -h, --help Show this help`);
@@ -15,7 +15,7 @@ Options:
15
15
  }
16
16
 
17
17
  const email = args[0];
18
- let plan = 'enterprise';
18
+ let plan = 'pro';
19
19
  let months = 1;
20
20
  let env = 'stage';
21
21
 
@@ -25,8 +25,8 @@ Options:
25
25
  else if (args[i] === '--env' && args[i + 1]) { env = args[++i]; }
26
26
  }
27
27
 
28
- if (!['free', 'pro', 'enterprise'].includes(plan)) {
29
- console.error(`Unknown plan: ${plan}. Available: free, pro, enterprise`);
28
+ if (!['trial', 'starter', 'pro', 'enterprise'].includes(plan)) {
29
+ console.error(`Unknown plan: ${plan}. Available: trial, starter, pro, enterprise`);
30
30
  process.exit(1);
31
31
  }
32
32
  if (months < 1) { console.error('Months must be >= 1'); process.exit(1); }
@@ -90,15 +90,21 @@ INSERT INTO credit_ledger (id, user_id, type, description, initial_amount, remai
90
90
  SELECT concat('crd_gift_', substr(md5(random()::text), 1, 16)), '${safeUserId}', 'subscription', '${safePlanName} plan gift (${months} month)', ${monthlyCredits}, ${monthlyCredits}, '${periodEndISO}', '${now}'
91
91
  WHERE ${monthlyCredits} > 0;
92
92
 
93
- -- Upsert session token quota
93
+ -- Update existing active session quota, or insert new one if none exists
94
+ UPDATE token_quotas SET plan_id='${safePlan}', monthly_limit=${sessionTokenLimit}, updated_at='${now}'
95
+ WHERE user_id='${safeUserId}' AND period_type='session' AND period_end > '${now}';
96
+
94
97
  INSERT INTO token_quotas (id, user_id, plan_id, period_type, monthly_limit, monthly_used, period_start, period_end, created_at, updated_at)
95
- VALUES (concat('tq_sess_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'session', ${sessionTokenLimit}, 0, '${now}', '${sessionEnd}', '${now}', '${now}')
96
- ON CONFLICT (user_id, period_type, period_start) DO UPDATE SET plan_id='${safePlan}', monthly_limit=${sessionTokenLimit}, updated_at='${now}';
98
+ SELECT concat('tq_sess_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'session', ${sessionTokenLimit}, 0, '${now}', '${sessionEnd}', '${now}', '${now}'
99
+ WHERE NOT EXISTS (SELECT 1 FROM token_quotas WHERE user_id='${safeUserId}' AND period_type='session' AND period_end > '${now}');
100
+
101
+ -- Update existing active weekly quota, or insert new one if none exists
102
+ UPDATE token_quotas SET plan_id='${safePlan}', monthly_limit=${weeklyTokenLimit}, updated_at='${now}'
103
+ WHERE user_id='${safeUserId}' AND period_type='weekly' AND period_end > '${now}';
97
104
 
98
- -- Upsert weekly token quota
99
105
  INSERT INTO token_quotas (id, user_id, plan_id, period_type, monthly_limit, monthly_used, period_start, period_end, created_at, updated_at)
100
- VALUES (concat('tq_week_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'weekly', ${weeklyTokenLimit}, 0, '${now}', '${weekEnd}', '${now}', '${now}')
101
- ON CONFLICT (user_id, period_type, period_start) DO UPDATE SET plan_id='${safePlan}', monthly_limit=${weeklyTokenLimit}, updated_at='${now}';
106
+ SELECT concat('tq_week_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'weekly', ${weeklyTokenLimit}, 0, '${now}', '${weekEnd}', '${now}', '${now}'
107
+ WHERE NOT EXISTS (SELECT 1 FROM token_quotas WHERE user_id='${safeUserId}' AND period_type='weekly' AND period_end > '${now}');
102
108
 
103
109
  COMMIT;
104
110
  `.trim();
@@ -7,14 +7,14 @@ function parseArgs(args) {
7
7
  console.log(`Usage: optima-grant-subscription <email> [options]
8
8
 
9
9
  Options:
10
- --plan <id> Plan: free, pro, enterprise (default: enterprise)
10
+ --plan <id> Plan: trial, starter, pro, enterprise (default: pro)
11
11
  --months <n> Duration in months (default: 1)
12
12
  --env <env> Environment: stage, prod (default: stage)
13
13
  -h, --help Show this help`);
14
14
  process.exit(0);
15
15
  }
16
16
  const email = args[0];
17
- let plan = 'enterprise';
17
+ let plan = 'pro';
18
18
  let months = 1;
19
19
  let env = 'stage';
20
20
  for (let i = 1; i < args.length; i++) {
@@ -28,8 +28,8 @@ Options:
28
28
  env = args[++i];
29
29
  }
30
30
  }
31
- if (!['free', 'pro', 'enterprise'].includes(plan)) {
32
- console.error(`Unknown plan: ${plan}. Available: free, pro, enterprise`);
31
+ if (!['trial', 'starter', 'pro', 'enterprise'].includes(plan)) {
32
+ console.error(`Unknown plan: ${plan}. Available: trial, starter, pro, enterprise`);
33
33
  process.exit(1);
34
34
  }
35
35
  if (months < 1) {
@@ -93,15 +93,21 @@ INSERT INTO credit_ledger (id, user_id, type, description, initial_amount, remai
93
93
  SELECT concat('crd_gift_', substr(md5(random()::text), 1, 16)), '${safeUserId}', 'subscription', '${safePlanName} plan gift (${months} month)', ${monthlyCredits}, ${monthlyCredits}, '${periodEndISO}', '${now}'
94
94
  WHERE ${monthlyCredits} > 0;
95
95
 
96
- -- Upsert session token quota
96
+ -- Update existing active session quota, or insert new one if none exists
97
+ UPDATE token_quotas SET plan_id='${safePlan}', monthly_limit=${sessionTokenLimit}, updated_at='${now}'
98
+ WHERE user_id='${safeUserId}' AND period_type='session' AND period_end > '${now}';
99
+
97
100
  INSERT INTO token_quotas (id, user_id, plan_id, period_type, monthly_limit, monthly_used, period_start, period_end, created_at, updated_at)
98
- VALUES (concat('tq_sess_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'session', ${sessionTokenLimit}, 0, '${now}', '${sessionEnd}', '${now}', '${now}')
99
- ON CONFLICT (user_id, period_type, period_start) DO UPDATE SET plan_id='${safePlan}', monthly_limit=${sessionTokenLimit}, updated_at='${now}';
101
+ SELECT concat('tq_sess_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'session', ${sessionTokenLimit}, 0, '${now}', '${sessionEnd}', '${now}', '${now}'
102
+ WHERE NOT EXISTS (SELECT 1 FROM token_quotas WHERE user_id='${safeUserId}' AND period_type='session' AND period_end > '${now}');
103
+
104
+ -- Update existing active weekly quota, or insert new one if none exists
105
+ UPDATE token_quotas SET plan_id='${safePlan}', monthly_limit=${weeklyTokenLimit}, updated_at='${now}'
106
+ WHERE user_id='${safeUserId}' AND period_type='weekly' AND period_end > '${now}';
100
107
 
101
- -- Upsert weekly token quota
102
108
  INSERT INTO token_quotas (id, user_id, plan_id, period_type, monthly_limit, monthly_used, period_start, period_end, created_at, updated_at)
103
- VALUES (concat('tq_week_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'weekly', ${weeklyTokenLimit}, 0, '${now}', '${weekEnd}', '${now}', '${now}')
104
- ON CONFLICT (user_id, period_type, period_start) DO UPDATE SET plan_id='${safePlan}', monthly_limit=${weeklyTokenLimit}, updated_at='${now}';
109
+ SELECT concat('tq_week_', substr(md5(random()::text), 1, 16)), '${safeUserId}', '${safePlan}', 'weekly', ${weeklyTokenLimit}, 0, '${now}', '${weekEnd}', '${now}', '${now}'
110
+ WHERE NOT EXISTS (SELECT 1 FROM token_quotas WHERE user_id='${safeUserId}' AND period_type='weekly' AND period_end > '${now}');
105
111
 
106
112
  COMMIT;
107
113
  `.trim();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@optima-chat/dev-skills",
3
- "version": "0.7.22",
3
+ "version": "0.7.24",
4
4
  "description": "Claude Code Skills for Optima development team - cross-environment collaboration tools",
5
5
  "main": "index.js",
6
6
  "bin": {