@rigstate/cli 0.7.32 → 0.7.35

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/index.cjs CHANGED
@@ -59,6 +59,24 @@ __export(config_exports, {
59
59
  setProjectId: () => setProjectId
60
60
  });
61
61
  function getApiKey() {
62
+ try {
63
+ const cwd = process.cwd();
64
+ const manifestPaths = [
65
+ import_path.default.join(cwd, ".rigstate", "identity.json"),
66
+ import_path.default.join(cwd, ".rigstate")
67
+ ];
68
+ for (const manifestPath of manifestPaths) {
69
+ if (import_fs.default.existsSync(manifestPath) && import_fs.default.statSync(manifestPath).isFile()) {
70
+ const content = import_fs.default.readFileSync(manifestPath, "utf-8");
71
+ const manifest = JSON.parse(content);
72
+ if (manifest.api_key) return manifest.api_key;
73
+ }
74
+ }
75
+ } catch (e) {
76
+ }
77
+ if (process.env.RIGSTATE_API_KEY) {
78
+ return process.env.RIGSTATE_API_KEY;
79
+ }
62
80
  const apiKey = config.get("apiKey");
63
81
  if (!apiKey) {
64
82
  throw new Error(
@@ -71,12 +89,54 @@ function setApiKey(key) {
71
89
  config.set("apiKey", key);
72
90
  }
73
91
  function getProjectId() {
74
- return config.get("projectId");
92
+ try {
93
+ const cwd = process.cwd();
94
+ const manifestPaths = [
95
+ import_path.default.join(cwd, ".rigstate", "identity.json"),
96
+ import_path.default.join(cwd, ".rigstate")
97
+ ];
98
+ for (const manifestPath of manifestPaths) {
99
+ if (import_fs.default.existsSync(manifestPath) && import_fs.default.statSync(manifestPath).isFile()) {
100
+ const content = import_fs.default.readFileSync(manifestPath, "utf-8");
101
+ const manifest = JSON.parse(content);
102
+ if (manifest.project_id) {
103
+ console.log(import_chalk.default.dim(` [Auth] Context: Project ID ${manifest.project_id.substring(0, 8)}... (from ${import_path.default.basename(manifestPath)})`));
104
+ return manifest.project_id;
105
+ }
106
+ }
107
+ }
108
+ } catch (e) {
109
+ console.log(import_chalk.default.red(` [Error] Failed to read context: ${e.message}`));
110
+ }
111
+ if (process.env.RIGSTATE_PROJECT_ID) {
112
+ console.log(import_chalk.default.dim(` [Auth] Context: Project ID ${process.env.RIGSTATE_PROJECT_ID.substring(0, 8)}... (from ENV)`));
113
+ return process.env.RIGSTATE_PROJECT_ID;
114
+ }
115
+ const globalId = config.get("projectId");
116
+ if (globalId) {
117
+ console.log(import_chalk.default.dim(` [Auth] Context: Project ID ${globalId.substring(0, 8)}... (from GLOBAL CONFIG)`));
118
+ }
119
+ return globalId;
75
120
  }
76
121
  function setProjectId(projectId) {
77
122
  config.set("projectId", projectId);
78
123
  }
79
124
  function getApiUrl() {
125
+ try {
126
+ const cwd = process.cwd();
127
+ const manifestPaths = [
128
+ import_path.default.join(cwd, ".rigstate", "identity.json"),
129
+ import_path.default.join(cwd, ".rigstate")
130
+ ];
131
+ for (const manifestPath of manifestPaths) {
132
+ if (import_fs.default.existsSync(manifestPath) && import_fs.default.statSync(manifestPath).isFile()) {
133
+ const content = import_fs.default.readFileSync(manifestPath, "utf-8");
134
+ const manifest = JSON.parse(content);
135
+ if (manifest.api_url) return manifest.api_url;
136
+ }
137
+ }
138
+ } catch (e) {
139
+ }
80
140
  if (process.env.RIGSTATE_API_URL) {
81
141
  return process.env.RIGSTATE_API_URL;
82
142
  }
@@ -92,12 +152,15 @@ function setApiUrl(url) {
92
152
  function clearConfig() {
93
153
  config.clear();
94
154
  }
95
- var import_conf, config;
155
+ var import_conf, import_chalk, import_fs, import_path, config;
96
156
  var init_config = __esm({
97
157
  "src/utils/config.ts"() {
98
158
  "use strict";
99
159
  init_cjs_shims();
100
160
  import_conf = __toESM(require("conf"), 1);
161
+ import_chalk = __toESM(require("chalk"), 1);
162
+ import_fs = __toESM(require("fs"), 1);
163
+ import_path = __toESM(require("path"), 1);
101
164
  config = new import_conf.default({
102
165
  projectName: "rigstate-cli",
103
166
  defaults: {
@@ -107,6 +170,66 @@ var init_config = __esm({
107
170
  }
108
171
  });
109
172
 
173
+ // src/utils/manifest.ts
174
+ var manifest_exports = {};
175
+ __export(manifest_exports, {
176
+ loadManifest: () => loadManifest,
177
+ saveManifest: () => saveManifest
178
+ });
179
+ async function loadManifest() {
180
+ const cwd = process.cwd();
181
+ const manifestPaths = [
182
+ import_path2.default.join(cwd, ".rigstate", "identity.json"),
183
+ import_path2.default.join(cwd, ".rigstate")
184
+ ];
185
+ for (const p of manifestPaths) {
186
+ try {
187
+ if (import_fs2.default.existsSync(p) && import_fs2.default.statSync(p).isFile()) {
188
+ const content = await import_promises.default.readFile(p, "utf-8");
189
+ const data = JSON.parse(content);
190
+ return {
191
+ project_id: data.project?.id || data.project_id,
192
+ api_url: data.api_url,
193
+ linked_at: data.linked_at || data.project?.created_at,
194
+ api_key: data.api_key
195
+ };
196
+ }
197
+ } catch (e) {
198
+ continue;
199
+ }
200
+ }
201
+ return null;
202
+ }
203
+ async function saveManifest(data) {
204
+ const cwd = process.cwd();
205
+ const rigstatePath = import_path2.default.join(cwd, ".rigstate");
206
+ let targetFile = rigstatePath;
207
+ try {
208
+ const stats = await import_promises.default.stat(rigstatePath);
209
+ if (stats.isDirectory()) {
210
+ targetFile = import_path2.default.join(rigstatePath, "identity.json");
211
+ }
212
+ } catch (e) {
213
+ }
214
+ const existing = await loadManifest() || {};
215
+ const merged = { ...existing, ...data };
216
+ if (targetFile.endsWith("identity.json")) {
217
+ await import_promises.default.mkdir(rigstatePath, { recursive: true });
218
+ }
219
+ await import_promises.default.writeFile(targetFile, JSON.stringify(merged, null, 2), "utf-8");
220
+ return targetFile;
221
+ }
222
+ var import_promises, import_fs2, import_path2;
223
+ var init_manifest = __esm({
224
+ "src/utils/manifest.ts"() {
225
+ "use strict";
226
+ init_cjs_shims();
227
+ import_promises = __toESM(require("fs/promises"), 1);
228
+ import_fs2 = __toESM(require("fs"), 1);
229
+ import_path2 = __toESM(require("path"), 1);
230
+ }
231
+ });
232
+
110
233
  // src/commands/env.ts
111
234
  var env_exports = {};
112
235
  __export(env_exports, {
@@ -116,9 +239,9 @@ __export(env_exports, {
116
239
  async function syncEnv(projectId, apiKey, apiUrl, silent = false) {
117
240
  if (!silent) {
118
241
  console.log("");
119
- console.log(import_chalk2.default.bold.yellow("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
120
- console.log(import_chalk2.default.bold.yellow("\u2551") + import_chalk2.default.bold.white(" \u{1F6E1}\uFE0F RIGSTATE SOVEREIGN VAULT SYNC \u{1F6E1}\uFE0F ") + import_chalk2.default.bold.yellow("\u2551"));
121
- console.log(import_chalk2.default.bold.yellow("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
242
+ console.log(import_chalk3.default.bold.yellow("\u2554\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2557"));
243
+ console.log(import_chalk3.default.bold.yellow("\u2551") + import_chalk3.default.bold.white(" \u{1F6E1}\uFE0F RIGSTATE SOVEREIGN VAULT SYNC \u{1F6E1}\uFE0F ") + import_chalk3.default.bold.yellow("\u2551"));
244
+ console.log(import_chalk3.default.bold.yellow("\u255A\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u255D"));
122
245
  console.log("");
123
246
  }
124
247
  const spinner = (0, import_ora.default)("Fetching secrets from Vault...").start();
@@ -135,15 +258,15 @@ async function syncEnv(projectId, apiKey, apiUrl, silent = false) {
135
258
  const secretCount = response.data.data.count || 0;
136
259
  if (secretCount === 0) {
137
260
  spinner.info("No secrets found in Vault for this project.");
138
- if (!silent) console.log(import_chalk2.default.dim(" Add secrets via the Rigstate web interface."));
261
+ if (!silent) console.log(import_chalk3.default.dim(" Add secrets via the Rigstate web interface."));
139
262
  return true;
140
263
  }
141
- spinner.succeed(`Retrieved ${import_chalk2.default.bold(secretCount)} secret(s)`);
142
- const envFile = import_path.default.resolve(process.cwd(), ".env.local");
264
+ spinner.succeed(`Retrieved ${import_chalk3.default.bold(secretCount)} secret(s)`);
265
+ const envFile = import_path3.default.resolve(process.cwd(), ".env.local");
143
266
  let existingContent = "";
144
267
  let existingKeys = /* @__PURE__ */ new Set();
145
268
  try {
146
- existingContent = await import_promises.default.readFile(envFile, "utf-8");
269
+ existingContent = await import_promises2.default.readFile(envFile, "utf-8");
147
270
  existingContent.split("\n").forEach((line) => {
148
271
  const match = line.match(/^([A-Z_][A-Z0-9_]*)=/);
149
272
  if (match) existingKeys.add(match[1]);
@@ -175,25 +298,25 @@ async function syncEnv(projectId, apiKey, apiUrl, silent = false) {
175
298
  "# ==========================================",
176
299
  ""
177
300
  ].join("\n");
178
- await import_promises.default.writeFile(envFile, header + vaultContent + "\n");
301
+ await import_promises2.default.writeFile(envFile, header + vaultContent + "\n");
179
302
  spinner.succeed("Written to .env.local");
180
303
  if (!silent) {
181
304
  console.log("");
182
- console.log(import_chalk2.default.bold.green("\u2705 Environment synchronized successfully"));
305
+ console.log(import_chalk3.default.bold.green("\u2705 Environment synchronized successfully"));
183
306
  console.log("");
184
- console.log(import_chalk2.default.dim(" Summary:"));
185
- console.log(import_chalk2.default.green(` + ${newCount} new`));
186
- console.log(import_chalk2.default.yellow(` ~ ${updatedCount} updated`));
187
- console.log(import_chalk2.default.dim(` = ${unchangedCount} unchanged`));
307
+ console.log(import_chalk3.default.dim(" Summary:"));
308
+ console.log(import_chalk3.default.green(` + ${newCount} new`));
309
+ console.log(import_chalk3.default.yellow(` ~ ${updatedCount} updated`));
310
+ console.log(import_chalk3.default.dim(` = ${unchangedCount} unchanged`));
188
311
  console.log("");
189
- console.log(import_chalk2.default.bold.yellow("\u26A0\uFE0F Security Reminder:"));
190
- console.log(import_chalk2.default.dim(" - Never commit .env.local to version control."));
191
- console.log(import_chalk2.default.dim(" - Ensure .gitignore includes .env.local"));
312
+ console.log(import_chalk3.default.bold.yellow("\u26A0\uFE0F Security Reminder:"));
313
+ console.log(import_chalk3.default.dim(" - Never commit .env.local to version control."));
314
+ console.log(import_chalk3.default.dim(" - Ensure .gitignore includes .env.local"));
192
315
  console.log("");
193
316
  }
194
317
  return true;
195
318
  } catch (e) {
196
- spinner.fail(import_chalk2.default.red(`Failed to fetch secrets: ${e.message}`));
319
+ spinner.fail(import_chalk3.default.red(`Failed to fetch secrets: ${e.message}`));
197
320
  return false;
198
321
  }
199
322
  }
@@ -205,21 +328,17 @@ function createEnvPullCommand() {
205
328
  try {
206
329
  apiKey = getApiKey();
207
330
  } catch (e) {
208
- console.error(import_chalk2.default.red('Not authenticated. Run "rigstate login" first.'));
331
+ console.error(import_chalk3.default.red('Not authenticated. Run "rigstate login" first.'));
209
332
  return;
210
333
  }
211
334
  projectId = getProjectId();
212
335
  if (!projectId) {
213
- try {
214
- const manifestPath = import_path.default.join(process.cwd(), ".rigstate");
215
- const content = await import_promises.default.readFile(manifestPath, "utf-8");
216
- const manifest = JSON.parse(content);
217
- projectId = manifest.project_id;
218
- } catch (e) {
219
- }
336
+ const { loadManifest: loadManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
337
+ const manifest = await loadManifest2();
338
+ if (manifest?.project_id) projectId = manifest.project_id;
220
339
  }
221
340
  if (!projectId) {
222
- console.error(import_chalk2.default.red('No project context. Run "rigstate link" first.'));
341
+ console.error(import_chalk3.default.red('No project context. Run "rigstate link" first.'));
223
342
  return;
224
343
  }
225
344
  const apiUrl = getApiUrl();
@@ -227,28 +346,40 @@ function createEnvPullCommand() {
227
346
  });
228
347
  return envPull;
229
348
  }
230
- var import_commander2, import_chalk2, import_ora, import_promises, import_path, import_axios;
349
+ var import_commander2, import_chalk3, import_ora, import_promises2, import_path3, import_axios;
231
350
  var init_env = __esm({
232
351
  "src/commands/env.ts"() {
233
352
  "use strict";
234
353
  init_cjs_shims();
235
354
  import_commander2 = require("commander");
236
- import_chalk2 = __toESM(require("chalk"), 1);
355
+ import_chalk3 = __toESM(require("chalk"), 1);
237
356
  import_ora = __toESM(require("ora"), 1);
238
- import_promises = __toESM(require("fs/promises"), 1);
239
- import_path = __toESM(require("path"), 1);
357
+ import_promises2 = __toESM(require("fs/promises"), 1);
358
+ import_path3 = __toESM(require("path"), 1);
240
359
  init_config();
241
360
  import_axios = __toESM(require("axios"), 1);
242
361
  }
243
362
  });
244
363
 
364
+ // src/utils/version.ts
365
+ async function checkVersion() {
366
+ }
367
+ var CLI_VERSION;
368
+ var init_version = __esm({
369
+ "src/utils/version.ts"() {
370
+ "use strict";
371
+ init_cjs_shims();
372
+ CLI_VERSION = "0.7.34";
373
+ }
374
+ });
375
+
245
376
  // src/commands/sync-rules.ts
246
377
  var sync_rules_exports = {};
247
378
  __export(sync_rules_exports, {
248
379
  createSyncRulesCommand: () => createSyncRulesCommand,
249
380
  syncProjectRules: () => syncProjectRules
250
381
  });
251
- async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
382
+ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false, version = CLI_VERSION) {
252
383
  const spinner = (0, import_ora2.default)("\u{1F6E1}\uFE0F Frank Protocol: Initializing retroactive sync...").start();
253
384
  let success = true;
254
385
  try {
@@ -263,7 +394,7 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
263
394
  const project = projectRes.data.data.projects[0];
264
395
  spinner.text = `Syncing rules for ${project.name}...`;
265
396
  if (dryRun) {
266
- spinner.succeed(import_chalk3.default.yellow(` [DRY-RUN] Would sync: ${project.name}`));
397
+ spinner.succeed(import_chalk4.default.yellow(` [DRY-RUN] Would sync: ${project.name}`));
267
398
  return true;
268
399
  }
269
400
  const syncResponse = await import_axios2.default.post(`${apiUrl}/api/v1/rules/sync`, {
@@ -273,9 +404,9 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
273
404
  });
274
405
  if (syncResponse.data.success) {
275
406
  if (syncResponse.data.data.github_synced) {
276
- spinner.succeed(import_chalk3.default.green(` \u2705 ${project.name} [${project.id}] \u2192 GitHub synced`));
407
+ spinner.succeed(import_chalk4.default.green(` \u2705 ${project.name} [${project.id}] \u2192 GitHub synced`));
277
408
  } else {
278
- spinner.info(import_chalk3.default.blue(` \u2139\uFE0F ${project.name} [${project.id}] \u2192 Rules generated (no GitHub)`));
409
+ spinner.info(import_chalk4.default.blue(` \u2139\uFE0F ${project.name} [${project.id}] \u2192 Rules generated (no GitHub)`));
279
410
  }
280
411
  const files = syncResponse.data.data.files;
281
412
  if (files && Array.isArray(files)) {
@@ -286,7 +417,7 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
286
417
  await fs26.mkdir(path28.dirname(filePath), { recursive: true });
287
418
  await fs26.writeFile(filePath, file.content, "utf-8");
288
419
  }
289
- console.log(import_chalk3.default.dim(` \u{1F4BE} Wrote ${files.length} rule files to local .cursor/rules/`));
420
+ console.log(import_chalk4.default.dim(` \u{1F4BE} Wrote ${files.length} rule files to local .cursor/rules/`));
290
421
  try {
291
422
  const masterPath = path28.join(process.cwd(), ".cursorrules");
292
423
  let masterContent = "";
@@ -300,7 +431,7 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
300
431
  const ruleList = files.map((f) => f.path).filter((p) => p.endsWith(".mdc")).map((p) => `- ${p}`).join("\n");
301
432
  const governanceBlock = `${START_MARKER}
302
433
  # \u{1F6E1}\uFE0F Rigstate Governance (Do not edit this block manually)
303
- # The following rules are enforced by the Rigstate Daemon (v${require2("../../package.json").version}).
434
+ # The following rules are enforced by the Rigstate Daemon (v${version}).
304
435
  # Failure to adhere to these rules will be flagged during the 'work' cycle.
305
436
 
306
437
  # YOU MUST ADHERE TO THESE PROACTIVE RULES:
@@ -321,20 +452,20 @@ ${END_MARKER}`;
321
452
  ${governanceBlock}` : governanceBlock;
322
453
  }
323
454
  await fs26.writeFile(masterPath, newContent, "utf-8");
324
- console.log(import_chalk3.default.dim(" \u{1F4DC} Updated master .cursorrules (Constitution enforced)"));
455
+ console.log(import_chalk4.default.dim(" \u{1F4DC} Updated master .cursorrules (Constitution enforced)"));
325
456
  } catch (e) {
326
- console.warn(import_chalk3.default.yellow(` \u26A0\uFE0F Could not update .cursorrules: ${e.message}`));
457
+ console.warn(import_chalk4.default.yellow(` \u26A0\uFE0F Could not update .cursorrules: ${e.message}`));
327
458
  }
328
459
  }
329
460
  console.log("");
330
- console.log(import_chalk3.default.cyan("\u{1F6E1}\uFE0F Frank Protocol v1.0 has been injected into the rules engine."));
331
- console.log(import_chalk3.default.dim(" All new chats will now boot with mandatory governance checks."));
461
+ console.log(import_chalk4.default.cyan("\u{1F6E1}\uFE0F Frank Protocol v1.0 has been injected into the rules engine."));
462
+ console.log(import_chalk4.default.dim(" All new chats will now boot with mandatory governance checks."));
332
463
  } else {
333
- spinner.warn(import_chalk3.default.yellow(` \u26A0\uFE0F ${project.name} \u2192 ${syncResponse.data.error || "Unknown error"}`));
464
+ spinner.warn(import_chalk4.default.yellow(` \u26A0\uFE0F ${project.name} \u2192 ${syncResponse.data.error || "Unknown error"}`));
334
465
  success = false;
335
466
  }
336
467
  } catch (e) {
337
- spinner.fail(import_chalk3.default.red(`Sync failed: ${e.message}`));
468
+ spinner.fail(import_chalk4.default.red(`Sync failed: ${e.message}`));
338
469
  success = false;
339
470
  }
340
471
  return success;
@@ -346,30 +477,29 @@ function createSyncRulesCommand() {
346
477
  try {
347
478
  apiKey = getApiKey();
348
479
  } catch (e) {
349
- console.error(import_chalk3.default.red('Not authenticated. Run "rigstate login" first.'));
480
+ console.error(import_chalk4.default.red('Not authenticated. Run "rigstate login" first.'));
350
481
  return;
351
482
  }
352
483
  const apiUrl = getApiUrl();
353
484
  if (options.project) {
354
485
  await syncProjectRules(options.project, apiKey, apiUrl, options.dryRun);
355
486
  } else {
356
- console.log(import_chalk3.default.yellow("Use --project <id> for now. (Mass sync logic awaiting migration)"));
487
+ console.log(import_chalk4.default.yellow("Use --project <id> for now. (Mass sync logic awaiting migration)"));
357
488
  }
358
489
  });
359
490
  return syncRules;
360
491
  }
361
- var import_commander3, import_chalk3, import_ora2, import_axios2, import_module, require2;
492
+ var import_commander3, import_chalk4, import_ora2, import_axios2;
362
493
  var init_sync_rules = __esm({
363
494
  "src/commands/sync-rules.ts"() {
364
495
  "use strict";
365
496
  init_cjs_shims();
366
497
  import_commander3 = require("commander");
367
- import_chalk3 = __toESM(require("chalk"), 1);
498
+ import_chalk4 = __toESM(require("chalk"), 1);
368
499
  import_ora2 = __toESM(require("ora"), 1);
369
500
  init_config();
370
501
  import_axios2 = __toESM(require("axios"), 1);
371
- import_module = require("module");
372
- require2 = (0, import_module.createRequire)(importMetaUrl);
502
+ init_version();
373
503
  }
374
504
  });
375
505
 
@@ -396,28 +526,28 @@ async function suggestNextMove(projectId, apiKey, apiUrl) {
396
526
  if (tasks.length === 0) return;
397
527
  const nextTask = tasks[0];
398
528
  console.log("");
399
- console.log(import_chalk4.default.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
400
- console.log(import_chalk4.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
401
- console.log(`${import_chalk4.default.bold("Active Phase:")} Implementation`);
402
- console.log(`${import_chalk4.default.bold("Next Mission:")} ${import_chalk4.default.cyan(nextTask.title)}`);
529
+ console.log(import_chalk5.default.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
530
+ console.log(import_chalk5.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
531
+ console.log(`${import_chalk5.default.bold("Active Phase:")} Implementation`);
532
+ console.log(`${import_chalk5.default.bold("Next Mission:")} ${import_chalk5.default.cyan(nextTask.title)}`);
403
533
  if (nextTask.role) {
404
- console.log(`${import_chalk4.default.bold("Required Role:")} ${import_chalk4.default.magenta(nextTask.role)}`);
534
+ console.log(`${import_chalk5.default.bold("Required Role:")} ${import_chalk5.default.magenta(nextTask.role)}`);
405
535
  }
406
536
  console.log("");
407
- console.log(import_chalk4.default.yellow("SUGGESTED NEXT MOVE:"));
408
- console.log(import_chalk4.default.white(`> rigstate work start ${nextTask.id} `) + import_chalk4.default.dim("(Start this task)"));
409
- console.log(import_chalk4.default.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + import_chalk4.default.dim("(Ask Architect)"));
410
- console.log(import_chalk4.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
537
+ console.log(import_chalk5.default.yellow("SUGGESTED NEXT MOVE:"));
538
+ console.log(import_chalk5.default.white(`> rigstate work start ${nextTask.id} `) + import_chalk5.default.dim("(Start this task)"));
539
+ console.log(import_chalk5.default.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + import_chalk5.default.dim("(Ask Architect)"));
540
+ console.log(import_chalk5.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
411
541
  console.log("");
412
542
  } catch (e) {
413
543
  }
414
544
  }
415
- var import_chalk4, import_axios3;
545
+ var import_chalk5, import_axios3;
416
546
  var init_suggest = __esm({
417
547
  "src/commands/suggest.ts"() {
418
548
  "use strict";
419
549
  init_cjs_shims();
420
- import_chalk4 = __toESM(require("chalk"), 1);
550
+ import_chalk5 = __toESM(require("chalk"), 1);
421
551
  import_axios3 = __toESM(require("axios"), 1);
422
552
  }
423
553
  });
@@ -450,18 +580,18 @@ async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
450
580
  }
451
581
  } catch (e) {
452
582
  const msg = e.response?.data?.error || e.message;
453
- console.log(import_chalk8.default.dim(` (Skills API not available: ${msg}, using core library)`));
583
+ console.log(import_chalk9.default.dim(` (Skills API not available: ${msg}, using core library)`));
454
584
  }
455
585
  if (skills.length === 0) {
456
586
  const { getRigstateStandardSkills } = await import("@rigstate/rules-engine");
457
587
  const coreSkills = getRigstateStandardSkills();
458
588
  skills.push(...coreSkills);
459
589
  }
460
- const skillsDir = import_path6.default.join(rootDir, ".agent", "skills");
461
- await import_promises6.default.mkdir(skillsDir, { recursive: true });
590
+ const skillsDir = import_path8.default.join(rootDir, ".agent", "skills");
591
+ await import_promises7.default.mkdir(skillsDir, { recursive: true });
462
592
  for (const skill of skills) {
463
- const skillDir = import_path6.default.join(skillsDir, skill.name);
464
- await import_promises6.default.mkdir(skillDir, { recursive: true });
593
+ const skillDir = import_path8.default.join(skillsDir, skill.name);
594
+ await import_promises7.default.mkdir(skillDir, { recursive: true });
465
595
  const skillContent = `---
466
596
  name: ${skill.name}
467
597
  description: ${skill.description}
@@ -474,10 +604,10 @@ ${skill.content}
474
604
 
475
605
  ---
476
606
  *Provisioned by Rigstate CLI. Do not modify manually.*`;
477
- const skillPath = import_path6.default.join(skillDir, "SKILL.md");
478
- await import_promises6.default.writeFile(skillPath, skillContent, "utf-8");
607
+ const skillPath = import_path8.default.join(skillDir, "SKILL.md");
608
+ await import_promises7.default.writeFile(skillPath, skillContent, "utf-8");
479
609
  }
480
- console.log(import_chalk8.default.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
610
+ console.log(import_chalk9.default.green(` \u2705 Provisioned ${skills.length} skill(s) to .agent/skills/`));
481
611
  return skills;
482
612
  }
483
613
  function generateSkillsDiscoveryBlock(skills) {
@@ -492,16 +622,16 @@ ${skillBlocks}
492
622
  </available_skills>`;
493
623
  }
494
624
  async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
495
- const rulesPath = import_path6.default.join(rootDir, ".cursorrules");
625
+ const rulesPath = import_path8.default.join(rootDir, ".cursorrules");
496
626
  let rulesContent = "";
497
627
  try {
498
- rulesContent = await import_promises6.default.readFile(rulesPath, "utf-8");
628
+ rulesContent = await import_promises7.default.readFile(rulesPath, "utf-8");
499
629
  } catch (e) {
500
630
  return false;
501
631
  }
502
632
  const isProvisioned = rulesContent.includes(`<name>${skillId}</name>`) || rulesContent.includes(`.agent/skills/${skillId}`);
503
633
  if (isProvisioned) return false;
504
- console.log(import_chalk8.default.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
634
+ console.log(import_chalk9.default.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
505
635
  try {
506
636
  const skills = await provisionSkills(apiUrl, apiKey, projectId, rootDir);
507
637
  const skillsBlock = generateSkillsDiscoveryBlock(skills);
@@ -516,22 +646,22 @@ async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
516
646
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
517
647
  }
518
648
  }
519
- await import_promises6.default.writeFile(rulesPath, rulesContent, "utf-8");
649
+ await import_promises7.default.writeFile(rulesPath, rulesContent, "utf-8");
520
650
  return true;
521
651
  } catch (e) {
522
- console.log(import_chalk8.default.red(` Failed to provision skill: ${e.message}`));
652
+ console.log(import_chalk9.default.red(` Failed to provision skill: ${e.message}`));
523
653
  return false;
524
654
  }
525
655
  }
526
- var import_axios6, import_promises6, import_path6, import_chalk8;
656
+ var import_axios6, import_promises7, import_path8, import_chalk9;
527
657
  var init_skills_provisioner = __esm({
528
658
  "src/utils/skills-provisioner.ts"() {
529
659
  "use strict";
530
660
  init_cjs_shims();
531
661
  import_axios6 = __toESM(require("axios"), 1);
532
- import_promises6 = __toESM(require("fs/promises"), 1);
533
- import_path6 = __toESM(require("path"), 1);
534
- import_chalk8 = __toESM(require("chalk"), 1);
662
+ import_promises7 = __toESM(require("fs/promises"), 1);
663
+ import_path8 = __toESM(require("path"), 1);
664
+ import_chalk9 = __toESM(require("chalk"), 1);
535
665
  }
536
666
  });
537
667
 
@@ -547,8 +677,8 @@ __export(governance_exports, {
547
677
  });
548
678
  async function getGovernanceConfig(rootDir = process.cwd()) {
549
679
  try {
550
- const configPath = import_path7.default.join(rootDir, "rigstate.config.json");
551
- const content = await import_promises7.default.readFile(configPath, "utf-8");
680
+ const configPath = import_path9.default.join(rootDir, "rigstate.config.json");
681
+ const content = await import_promises8.default.readFile(configPath, "utf-8");
552
682
  const userConfig = JSON.parse(content);
553
683
  return {
554
684
  governance: {
@@ -562,50 +692,50 @@ async function getGovernanceConfig(rootDir = process.cwd()) {
562
692
  }
563
693
  async function getSessionState(rootDir = process.cwd()) {
564
694
  try {
565
- const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
566
- const content = await import_promises7.default.readFile(sessionPath, "utf-8");
695
+ const sessionPath = import_path9.default.join(rootDir, ".rigstate", "session.json");
696
+ const content = await import_promises8.default.readFile(sessionPath, "utf-8");
567
697
  return JSON.parse(content);
568
698
  } catch (e) {
569
699
  return DEFAULT_SESSION;
570
700
  }
571
701
  }
572
702
  async function setSoftLock(reason, violationId, rootDir = process.cwd()) {
573
- const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
703
+ const sessionPath = import_path9.default.join(rootDir, ".rigstate", "session.json");
574
704
  const state = {
575
705
  status: "SOFT_LOCK",
576
706
  active_violation: violationId,
577
707
  lock_reason: reason,
578
708
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
579
709
  };
580
- await import_promises7.default.mkdir(import_path7.default.dirname(sessionPath), { recursive: true });
581
- await import_promises7.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
710
+ await import_promises8.default.mkdir(import_path9.default.dirname(sessionPath), { recursive: true });
711
+ await import_promises8.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
582
712
  }
583
713
  async function clearSoftLock(rootDir = process.cwd()) {
584
- const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
714
+ const sessionPath = import_path9.default.join(rootDir, ".rigstate", "session.json");
585
715
  const state = {
586
716
  ...DEFAULT_SESSION,
587
717
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
588
718
  };
589
- await import_promises7.default.mkdir(import_path7.default.dirname(sessionPath), { recursive: true });
590
- await import_promises7.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
719
+ await import_promises8.default.mkdir(import_path9.default.dirname(sessionPath), { recursive: true });
720
+ await import_promises8.default.writeFile(sessionPath, JSON.stringify(state, null, 2), "utf-8");
591
721
  }
592
722
  async function performOverride(violationId, reason, rootDir = process.cwd()) {
593
723
  const config2 = await getGovernanceConfig(rootDir);
594
724
  if (!config2.governance.allow_overrides) {
595
- console.log(import_chalk9.default.red("\u274C Overrides are disabled for this project."));
725
+ console.log(import_chalk10.default.red("\u274C Overrides are disabled for this project."));
596
726
  return false;
597
727
  }
598
728
  await clearSoftLock(rootDir);
599
729
  return true;
600
730
  }
601
- var import_promises7, import_path7, import_chalk9, InterventionLevel, DEFAULT_CONFIG, DEFAULT_SESSION;
731
+ var import_promises8, import_path9, import_chalk10, InterventionLevel, DEFAULT_CONFIG, DEFAULT_SESSION;
602
732
  var init_governance = __esm({
603
733
  "src/utils/governance.ts"() {
604
734
  "use strict";
605
735
  init_cjs_shims();
606
- import_promises7 = __toESM(require("fs/promises"), 1);
607
- import_path7 = __toESM(require("path"), 1);
608
- import_chalk9 = __toESM(require("chalk"), 1);
736
+ import_promises8 = __toESM(require("fs/promises"), 1);
737
+ import_path9 = __toESM(require("path"), 1);
738
+ import_chalk10 = __toESM(require("chalk"), 1);
609
739
  InterventionLevel = /* @__PURE__ */ ((InterventionLevel2) => {
610
740
  InterventionLevel2[InterventionLevel2["GHOST"] = 0] = "GHOST";
611
741
  InterventionLevel2[InterventionLevel2["NUDGE"] = 1] = "NUDGE";
@@ -634,16 +764,16 @@ __export(watchdog_exports, {
634
764
  });
635
765
  async function countLines(filePath) {
636
766
  try {
637
- const content = await import_promises8.default.readFile(filePath, "utf-8");
767
+ const content = await import_promises9.default.readFile(filePath, "utf-8");
638
768
  return content.split("\n").length;
639
769
  } catch (e) {
640
770
  return 0;
641
771
  }
642
772
  }
643
773
  async function getFiles(dir, extension) {
644
- const entries = await import_promises8.default.readdir(dir, { withFileTypes: true });
774
+ const entries = await import_promises9.default.readdir(dir, { withFileTypes: true });
645
775
  const files = await Promise.all(entries.map(async (entry) => {
646
- const res = import_path8.default.resolve(dir, entry.name);
776
+ const res = import_path10.default.resolve(dir, entry.name);
647
777
  if (entry.isDirectory()) {
648
778
  if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".next" || entry.name === "dist") return [];
649
779
  return getFiles(res, extension);
@@ -671,8 +801,8 @@ async function fetchRulesFromApi(projectId) {
671
801
  }
672
802
  } catch (error) {
673
803
  try {
674
- const cachePath = import_path8.default.join(process.cwd(), CACHE_FILE);
675
- const content = await import_promises8.default.readFile(cachePath, "utf-8");
804
+ const cachePath = import_path10.default.join(process.cwd(), CACHE_FILE);
805
+ const content = await import_promises9.default.readFile(cachePath, "utf-8");
676
806
  const cached = JSON.parse(content);
677
807
  if (cached.settings) {
678
808
  return {
@@ -691,7 +821,7 @@ async function fetchRulesFromApi(projectId) {
691
821
  };
692
822
  }
693
823
  async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
694
- console.log(import_chalk10.default.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
824
+ console.log(import_chalk11.default.bold("\n\u{1F6E1}\uFE0F Active Guardian Watchdog Initiated..."));
695
825
  let lmax = settings.lmax || DEFAULT_LMAX;
696
826
  let lmaxWarning = settings.lmax_warning || DEFAULT_LMAX_WARNING;
697
827
  let ruleSource = settings.lmax ? "Settings (Passed)" : "Default";
@@ -701,47 +831,47 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
701
831
  lmaxWarning = apiRules.lmaxWarning;
702
832
  ruleSource = apiRules.source;
703
833
  }
704
- console.log(import_chalk10.default.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
834
+ console.log(import_chalk11.default.dim(`Governance Rules: L_max=${lmax}, L_max_warning=${lmaxWarning}, Source: ${ruleSource}`));
705
835
  const targetExtensions = [".ts", ".tsx"];
706
836
  let scanTarget = rootPath;
707
- const webSrc = import_path8.default.join(rootPath, "apps", "web", "src");
837
+ const webSrc = import_path10.default.join(rootPath, "apps", "web", "src");
708
838
  try {
709
- await import_promises8.default.access(webSrc);
839
+ await import_promises9.default.access(webSrc);
710
840
  scanTarget = webSrc;
711
841
  } catch {
712
842
  }
713
- console.log(import_chalk10.default.dim(`Scanning target: ${import_path8.default.relative(process.cwd(), scanTarget)}`));
843
+ console.log(import_chalk11.default.dim(`Scanning target: ${import_path10.default.relative(process.cwd(), scanTarget)}`));
714
844
  const files = await getFiles(scanTarget, targetExtensions);
715
845
  let violations = 0;
716
846
  let warnings = 0;
717
847
  const results = [];
718
848
  for (const file of files) {
719
849
  const lines = await countLines(file);
720
- const relPath = import_path8.default.relative(rootPath, file);
850
+ const relPath = import_path10.default.relative(rootPath, file);
721
851
  if (lines > lmax) {
722
852
  results.push({ file: relPath, lines, status: "VIOLATION" });
723
853
  violations++;
724
- console.log(import_chalk10.default.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
854
+ console.log(import_chalk11.default.red(`[VIOLATION] ${relPath}: ${lines} lines (Limit: ${lmax})`));
725
855
  } else if (lines > lmaxWarning) {
726
856
  results.push({ file: relPath, lines, status: "WARNING" });
727
857
  warnings++;
728
- console.log(import_chalk10.default.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
858
+ console.log(import_chalk11.default.yellow(`[WARNING] ${relPath}: ${lines} lines (Threshold: ${lmaxWarning})`));
729
859
  }
730
860
  }
731
861
  if (violations === 0 && warnings === 0) {
732
- console.log(import_chalk10.default.green(`\u2714 All ${files.length} files are within governance limits.`));
862
+ console.log(import_chalk11.default.green(`\u2714 All ${files.length} files are within governance limits.`));
733
863
  } else {
734
- console.log("\n" + import_chalk10.default.bold("Summary:"));
735
- console.log(import_chalk10.default.red(`Violations: ${violations}`));
736
- console.log(import_chalk10.default.yellow(`Warnings: ${warnings}`));
864
+ console.log("\n" + import_chalk11.default.bold("Summary:"));
865
+ console.log(import_chalk11.default.red(`Violations: ${violations}`));
866
+ console.log(import_chalk11.default.yellow(`Warnings: ${warnings}`));
737
867
  const { getGovernanceConfig: getGovernanceConfig2, setSoftLock: setSoftLock2, InterventionLevel: InterventionLevel2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
738
868
  const { governance } = await getGovernanceConfig2(rootPath);
739
- console.log(import_chalk10.default.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
869
+ console.log(import_chalk11.default.dim(`Intervention Level: ${InterventionLevel2[governance.intervention_level] || "UNKNOWN"} (${governance.intervention_level})`));
740
870
  if (violations > 0) {
741
- console.log(import_chalk10.default.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
871
+ console.log(import_chalk11.default.red.bold("\nCRITICAL: Governance violations detected. Immediate refactoring required."));
742
872
  if (governance.intervention_level >= InterventionLevel2.SENTINEL) {
743
- console.log(import_chalk10.default.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
744
- console.log(import_chalk10.default.red(' Run "rigstate override <id> --reason \\"...\\"" if this is an emergency.'));
873
+ console.log(import_chalk11.default.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
874
+ console.log(import_chalk11.default.red(' Run "rigstate override <id> --reason \\"...\\"" if this is an emergency.'));
745
875
  await setSoftLock2("Sentinel Mode: Governance Violations Detected", "ARC-VIOLATION", rootPath);
746
876
  }
747
877
  }
@@ -764,20 +894,20 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
764
894
  }, {
765
895
  headers: { Authorization: `Bearer ${apiKey}` }
766
896
  });
767
- console.log(import_chalk10.default.dim("\u2714 Violations synced to Rigstate Cloud."));
897
+ console.log(import_chalk11.default.dim("\u2714 Violations synced to Rigstate Cloud."));
768
898
  } catch (e) {
769
- console.log(import_chalk10.default.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
899
+ console.log(import_chalk11.default.dim("\u26A0 Cloud sync skipped: " + (e.message || "Unknown")));
770
900
  }
771
901
  }
772
902
  }
773
- var import_promises8, import_path8, import_chalk10, import_axios7, DEFAULT_LMAX, DEFAULT_LMAX_WARNING, CACHE_FILE;
903
+ var import_promises9, import_path10, import_chalk11, import_axios7, DEFAULT_LMAX, DEFAULT_LMAX_WARNING, CACHE_FILE;
774
904
  var init_watchdog = __esm({
775
905
  "src/utils/watchdog.ts"() {
776
906
  "use strict";
777
907
  init_cjs_shims();
778
- import_promises8 = __toESM(require("fs/promises"), 1);
779
- import_path8 = __toESM(require("path"), 1);
780
- import_chalk10 = __toESM(require("chalk"), 1);
908
+ import_promises9 = __toESM(require("fs/promises"), 1);
909
+ import_path10 = __toESM(require("path"), 1);
910
+ import_chalk11 = __toESM(require("chalk"), 1);
781
911
  import_axios7 = __toESM(require("axios"), 1);
782
912
  init_config();
783
913
  DEFAULT_LMAX = 400;
@@ -1667,7 +1797,7 @@ var require_package = __commonJS({
1667
1797
  "package.json"(exports2, module2) {
1668
1798
  module2.exports = {
1669
1799
  name: "@rigstate/cli",
1670
- version: "0.7.32",
1800
+ version: "0.7.34",
1671
1801
  description: "Rigstate CLI - Code audit, sync and supervision tool",
1672
1802
  type: "module",
1673
1803
  main: "./dist/index.js",
@@ -1724,32 +1854,32 @@ var require_package = __commonJS({
1724
1854
  // src/index.ts
1725
1855
  init_cjs_shims();
1726
1856
  var import_commander24 = require("commander");
1727
- var import_chalk35 = __toESM(require("chalk"), 1);
1857
+ var import_chalk36 = __toESM(require("chalk"), 1);
1728
1858
 
1729
1859
  // src/commands/login.ts
1730
1860
  init_cjs_shims();
1731
1861
  var import_commander = require("commander");
1732
- var import_chalk = __toESM(require("chalk"), 1);
1862
+ var import_chalk2 = __toESM(require("chalk"), 1);
1733
1863
  init_config();
1734
1864
  function createLoginCommand() {
1735
1865
  return new import_commander.Command("login").description("Authenticate with your Rigstate API key").argument("<api-key>", "Your Rigstate API key (starts with sk_)").action(async (apiKey) => {
1736
1866
  try {
1737
1867
  if (!apiKey || !apiKey.startsWith("sk_rigstate_")) {
1738
- console.error(import_chalk.default.red("\u274C Invalid API key format"));
1739
- console.error(import_chalk.default.dim('API keys must start with "sk_rigstate_"'));
1868
+ console.error(import_chalk2.default.red("\u274C Invalid API key format"));
1869
+ console.error(import_chalk2.default.dim('API keys must start with "sk_rigstate_"'));
1740
1870
  process.exit(1);
1741
1871
  }
1742
1872
  setApiKey(apiKey);
1743
- console.log(import_chalk.default.green("\u2705 Successfully logged in!"));
1873
+ console.log(import_chalk2.default.green("\u2705 Successfully logged in!"));
1744
1874
  console.log(
1745
- import_chalk.default.dim(
1875
+ import_chalk2.default.dim(
1746
1876
  `
1747
1877
  Your API key has been securely stored. You can now use "rigstate scan" to audit your code.`
1748
1878
  )
1749
1879
  );
1750
- console.log(import_chalk.default.bold("\n\u{1F916} Cursor MCP Configuration"));
1751
- console.log(import_chalk.default.dim("Copy and paste this into Cursor Settings -> Features -> MCP:"));
1752
- console.log(import_chalk.default.cyan(`
1880
+ console.log(import_chalk2.default.bold("\n\u{1F916} Cursor MCP Configuration"));
1881
+ console.log(import_chalk2.default.dim("Copy and paste this into Cursor Settings -> Features -> MCP:"));
1882
+ console.log(import_chalk2.default.cyan(`
1753
1883
  {
1754
1884
  "mcpServers": {
1755
1885
  "rigstate": {
@@ -1766,7 +1896,7 @@ Your API key has been securely stored. You can now use "rigstate scan" to audit
1766
1896
  }`));
1767
1897
  } catch (error) {
1768
1898
  console.error(
1769
- import_chalk.default.red("\u274C Login failed:"),
1899
+ import_chalk2.default.red("\u274C Login failed:"),
1770
1900
  error instanceof Error ? error.message : "Unknown error"
1771
1901
  );
1772
1902
  process.exit(1);
@@ -1777,25 +1907,25 @@ Your API key has been securely stored. You can now use "rigstate scan" to audit
1777
1907
  // src/commands/link.ts
1778
1908
  init_cjs_shims();
1779
1909
  var import_commander4 = require("commander");
1780
- var import_promises2 = __toESM(require("fs/promises"), 1);
1781
- var import_path2 = __toESM(require("path"), 1);
1782
- var import_chalk5 = __toESM(require("chalk"), 1);
1910
+ var import_promises3 = __toESM(require("fs/promises"), 1);
1911
+ var import_path4 = __toESM(require("path"), 1);
1912
+ var import_chalk6 = __toESM(require("chalk"), 1);
1783
1913
  var import_os = __toESM(require("os"), 1);
1784
1914
  init_config();
1785
1915
  function createLinkCommand() {
1786
1916
  return new import_commander4.Command("link").description("Link current directory to a Rigstate project").argument("[projectId]", "Project ID to link").action(async (projectId) => {
1787
1917
  try {
1788
- const globalPath = import_path2.default.join(import_os.default.homedir(), ".rigstate", "config.json");
1789
- const globalData = await import_promises2.default.readFile(globalPath, "utf-8").catch(() => null);
1918
+ const globalPath = import_path4.default.join(import_os.default.homedir(), ".rigstate", "config.json");
1919
+ const globalData = await import_promises3.default.readFile(globalPath, "utf-8").catch(() => null);
1790
1920
  if (globalData) {
1791
1921
  const config2 = JSON.parse(globalData);
1792
- const cwd = process.cwd();
1793
- if (config2.overrides && config2.overrides[cwd]) {
1794
- const overrideId = config2.overrides[cwd];
1795
- console.warn(import_chalk5.default.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1922
+ const cwd2 = process.cwd();
1923
+ if (config2.overrides && config2.overrides[cwd2]) {
1924
+ const overrideId = config2.overrides[cwd2];
1925
+ console.warn(import_chalk6.default.yellow(`Global override detected. Enforcing project ID: ${overrideId}`));
1796
1926
  if (!projectId) projectId = overrideId;
1797
1927
  else if (projectId !== overrideId) {
1798
- console.warn(import_chalk5.default.red(`Ignoring provided ID ${projectId}. Using override.`));
1928
+ console.warn(import_chalk6.default.red(`Ignoring provided ID ${projectId}. Using override.`));
1799
1929
  projectId = overrideId;
1800
1930
  }
1801
1931
  }
@@ -1809,16 +1939,16 @@ function createLinkCommand() {
1809
1939
  const apiKey = getApiKey();
1810
1940
  const apiUrl = getApiUrl();
1811
1941
  if (!apiKey) {
1812
- console.error(import_chalk5.default.red('Not authenticated. Please run "rigstate login" or provide a Project ID.'));
1942
+ console.error(import_chalk6.default.red('Not authenticated. Please run "rigstate login" or provide a Project ID.'));
1813
1943
  process.exit(1);
1814
1944
  }
1815
- console.log(import_chalk5.default.dim("Fetching your projects..."));
1945
+ console.log(import_chalk6.default.dim("Fetching your projects..."));
1816
1946
  const axios24 = (await import("axios")).default;
1817
1947
  const response = await axios24.get(`${apiUrl}/api/v1/projects`, {
1818
1948
  headers: { Authorization: `Bearer ${apiKey}` }
1819
1949
  });
1820
1950
  if (!response.data.success || !response.data.data.projects?.length) {
1821
- console.error(import_chalk5.default.yellow("No projects found. Create one at https://app.rigstate.com"));
1951
+ console.error(import_chalk6.default.yellow("No projects found. Create one at https://app.rigstate.com"));
1822
1952
  process.exit(1);
1823
1953
  }
1824
1954
  const choices = response.data.data.projects.map((p) => ({
@@ -1833,54 +1963,49 @@ function createLinkCommand() {
1833
1963
  }]);
1834
1964
  projectId = answer.id;
1835
1965
  } catch (e) {
1836
- console.error(import_chalk5.default.red(`Failed to fetch projects: ${e.message}`));
1966
+ console.error(import_chalk6.default.red(`Failed to fetch projects: ${e.message}`));
1837
1967
  console.error("Please provide project ID manually: rigstate link <id>");
1838
1968
  process.exit(1);
1839
1969
  }
1840
1970
  }
1841
- const manifestPath = import_path2.default.join(process.cwd(), ".rigstate");
1842
- const content = {
1843
- project_id: projectId,
1844
- linked_at: (/* @__PURE__ */ new Date()).toISOString()
1845
- };
1846
- const currentUrl = getApiUrl();
1847
- if (currentUrl !== "https://app.rigstate.com") {
1848
- content.api_url = currentUrl;
1849
- }
1971
+ const cwd = process.cwd();
1850
1972
  try {
1851
- await import_promises2.default.mkdir(import_path2.default.dirname(manifestPath), { recursive: true });
1852
- await import_promises2.default.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
1853
- console.log(import_chalk5.default.green(`\u2714 Linked to project ID: ${projectId}`));
1854
- console.log(import_chalk5.default.dim(`Created local context manifest at .rigstate`));
1973
+ const { saveManifest: saveManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
1974
+ const targetFile = await saveManifest2({
1975
+ project_id: projectId,
1976
+ linked_at: (/* @__PURE__ */ new Date()).toISOString(),
1977
+ api_url: getApiUrl() !== "https://app.rigstate.com" ? getApiUrl() : void 0
1978
+ });
1979
+ console.log(import_chalk6.default.green(`\u2714 Linked to project ID: ${projectId}`));
1980
+ console.log(import_chalk6.default.dim(`Created local identity manifest at ${import_path4.default.relative(cwd, targetFile)}`));
1855
1981
  console.log("");
1856
- console.log(import_chalk5.default.bold("\u{1F916} Rigstate Automation Detected"));
1982
+ console.log(import_chalk6.default.bold("\u{1F916} Rigstate Automation Detected"));
1857
1983
  console.log("");
1858
- const { getApiKey: _getApiKey, getApiUrl: _getApiUrl } = await Promise.resolve().then(() => (init_config(), config_exports));
1859
1984
  const apiKey = getApiKey();
1860
1985
  const apiUrl = getApiUrl();
1861
1986
  if (apiKey) {
1862
- console.log(import_chalk5.default.blue("\u{1F510} Checking Vault for secrets..."));
1987
+ console.log(import_chalk6.default.blue("\u{1F510} Checking Vault for secrets..."));
1863
1988
  const { syncEnv: syncEnv2 } = await Promise.resolve().then(() => (init_env(), env_exports));
1864
1989
  await syncEnv2(projectId, apiKey, apiUrl, true);
1865
- console.log(import_chalk5.default.blue("\u{1F9E0} Syncing neural instructions..."));
1990
+ console.log(import_chalk6.default.blue("\u{1F9E0} Syncing neural instructions..."));
1866
1991
  const { syncProjectRules: syncProjectRules2 } = await Promise.resolve().then(() => (init_sync_rules(), sync_rules_exports));
1867
1992
  await syncProjectRules2(projectId, apiKey, apiUrl);
1868
- console.log(import_chalk5.default.blue("\u{1F6E1}\uFE0F Injecting Guardian hooks & Safety nets..."));
1993
+ console.log(import_chalk6.default.blue("\u{1F6E1}\uFE0F Injecting Guardian hooks & Safety nets..."));
1869
1994
  await installHooks(process.cwd());
1870
1995
  await hardenGitIgnore(process.cwd());
1871
1996
  console.log("");
1872
- console.log(import_chalk5.default.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1997
+ console.log(import_chalk6.default.bold.green("\u{1F680} Link Complete! Your environment is ready."));
1873
1998
  const { suggestNextMove: suggestNextMove2 } = await Promise.resolve().then(() => (init_suggest(), suggest_exports));
1874
1999
  await suggestNextMove2(projectId, apiKey, apiUrl);
1875
2000
  } else {
1876
2001
  console.log("");
1877
- console.log(import_chalk5.default.bold.green("\u{1F680} Link Complete!"));
2002
+ console.log(import_chalk6.default.bold.green("\u{1F680} Link Complete!"));
1878
2003
  }
1879
2004
  } catch (error) {
1880
2005
  if (error.message?.includes("Not authenticated")) {
1881
- console.warn(import_chalk5.default.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
2006
+ console.warn(import_chalk6.default.yellow('\u26A0\uFE0F Not authenticated. Run "rigstate login" to enable automation features.'));
1882
2007
  } else {
1883
- console.error(import_chalk5.default.red(`Failed to link project: ${error.message}`));
2008
+ console.error(import_chalk6.default.red(`Failed to link project: ${error.message}`));
1884
2009
  }
1885
2010
  }
1886
2011
  });
@@ -1909,15 +2034,15 @@ async function hardenGitIgnore(cwd) {
1909
2034
  }
1910
2035
  const missing = REQUIRED_IGNORES.filter((line) => !content.includes(line) && !line.startsWith("#"));
1911
2036
  if (missing.length > 0) {
1912
- console.log(import_chalk5.default.dim(" Configuring .gitignore for Rigstate safety..."));
2037
+ console.log(import_chalk6.default.dim(" Configuring .gitignore for Rigstate safety..."));
1913
2038
  const toAppend = "\n\n" + REQUIRED_IGNORES.join("\n") + "\n";
1914
2039
  await fs26.writeFile(ignorePath, content + toAppend, "utf-8");
1915
- console.log(import_chalk5.default.green(" \u2714 .gitignore updated (Artifacts protected)"));
2040
+ console.log(import_chalk6.default.green(" \u2714 .gitignore updated (Artifacts protected)"));
1916
2041
  } else {
1917
- console.log(import_chalk5.default.green(" \u2714 .gitignore already hardened"));
2042
+ console.log(import_chalk6.default.green(" \u2714 .gitignore already hardened"));
1918
2043
  }
1919
2044
  } catch (e) {
1920
- console.warn(import_chalk5.default.yellow(` Could not update .gitignore: ${e.message}`));
2045
+ console.warn(import_chalk6.default.yellow(` Could not update .gitignore: ${e.message}`));
1921
2046
  }
1922
2047
  }
1923
2048
  async function installHooks(cwd) {
@@ -1926,7 +2051,7 @@ async function installHooks(cwd) {
1926
2051
  try {
1927
2052
  await fs26.access(path28.join(cwd, ".git"));
1928
2053
  } catch {
1929
- console.log(import_chalk5.default.dim(" (Not a git repository, skipping hooks)"));
2054
+ console.log(import_chalk6.default.dim(" (Not a git repository, skipping hooks)"));
1930
2055
  return;
1931
2056
  }
1932
2057
  const hooksDir = path28.join(cwd, ".husky");
@@ -1937,7 +2062,7 @@ async function installHooks(cwd) {
1937
2062
  await fs26.access(preCommitPath);
1938
2063
  const content = await fs26.readFile(preCommitPath, "utf-8");
1939
2064
  if (content.includes("rigstate")) {
1940
- console.log(import_chalk5.default.green(" \u2714 Git hooks already active"));
2065
+ console.log(import_chalk6.default.green(" \u2714 Git hooks already active"));
1941
2066
  } else {
1942
2067
  shouldInstall = true;
1943
2068
  }
@@ -1966,10 +2091,10 @@ exit $?
1966
2091
  } else {
1967
2092
  await fs26.writeFile(preCommitPath, PRE_COMMIT_SCRIPT2, { mode: 493 });
1968
2093
  }
1969
- console.log(import_chalk5.default.green(" \u2714 Applied Guardian protection (git-hooks)"));
2094
+ console.log(import_chalk6.default.green(" \u2714 Applied Guardian protection (git-hooks)"));
1970
2095
  }
1971
2096
  } catch (e) {
1972
- console.log(import_chalk5.default.dim(" (Skipped hooks: " + e.message + ")"));
2097
+ console.log(import_chalk6.default.dim(" (Skipped hooks: " + e.message + ")"));
1973
2098
  }
1974
2099
  }
1975
2100
  async function fileExists(path28) {
@@ -1985,22 +2110,22 @@ async function fileExists(path28) {
1985
2110
  // src/commands/scan.ts
1986
2111
  init_cjs_shims();
1987
2112
  var import_commander5 = require("commander");
1988
- var import_chalk6 = __toESM(require("chalk"), 1);
2113
+ var import_chalk7 = __toESM(require("chalk"), 1);
1989
2114
  var import_ora3 = __toESM(require("ora"), 1);
1990
2115
  var import_axios4 = __toESM(require("axios"), 1);
1991
2116
  var import_glob = require("glob");
1992
- var import_promises4 = __toESM(require("fs/promises"), 1);
1993
- var import_path4 = __toESM(require("path"), 1);
2117
+ var import_promises5 = __toESM(require("fs/promises"), 1);
2118
+ var import_path6 = __toESM(require("path"), 1);
1994
2119
  init_config();
1995
2120
 
1996
2121
  // src/utils/files.ts
1997
2122
  init_cjs_shims();
1998
- var import_promises3 = __toESM(require("fs/promises"), 1);
1999
- var import_path3 = __toESM(require("path"), 1);
2123
+ var import_promises4 = __toESM(require("fs/promises"), 1);
2124
+ var import_path5 = __toESM(require("path"), 1);
2000
2125
  async function readGitignore(dir) {
2001
- const gitignorePath = import_path3.default.join(dir, ".gitignore");
2126
+ const gitignorePath = import_path5.default.join(dir, ".gitignore");
2002
2127
  try {
2003
- const content = await import_promises3.default.readFile(gitignorePath, "utf-8");
2128
+ const content = await import_promises4.default.readFile(gitignorePath, "utf-8");
2004
2129
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
2005
2130
  } catch (error) {
2006
2131
  return [];
@@ -2062,7 +2187,7 @@ function isCodeFile(filePath) {
2062
2187
  ".vue",
2063
2188
  ".svelte"
2064
2189
  ];
2065
- const ext = import_path3.default.extname(filePath).toLowerCase();
2190
+ const ext = import_path5.default.extname(filePath).toLowerCase();
2066
2191
  return codeExtensions.includes(ext);
2067
2192
  }
2068
2193
 
@@ -2076,26 +2201,26 @@ function createScanCommand() {
2076
2201
  const projectId = options.project || getProjectId();
2077
2202
  if (!projectId) {
2078
2203
  console.warn(
2079
- import_chalk6.default.yellow(
2204
+ import_chalk7.default.yellow(
2080
2205
  "\u26A0\uFE0F No project ID specified. Use --project <id> or set a default."
2081
2206
  )
2082
2207
  );
2083
2208
  }
2084
- const scanPath = import_path4.default.resolve(process.cwd(), targetPath);
2085
- spinner.start(`Scanning ${import_chalk6.default.cyan(scanPath)}...`);
2209
+ const scanPath = import_path6.default.resolve(process.cwd(), targetPath);
2210
+ spinner.start(`Scanning ${import_chalk7.default.cyan(scanPath)}...`);
2086
2211
  const gitignorePatterns = await readGitignore(scanPath);
2087
- const pattern = import_path4.default.join(scanPath, "**/*");
2212
+ const pattern = import_path6.default.join(scanPath, "**/*");
2088
2213
  const allFiles = await (0, import_glob.glob)(pattern, {
2089
2214
  nodir: true,
2090
2215
  dot: false,
2091
2216
  ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**"]
2092
2217
  });
2093
2218
  const codeFiles = allFiles.filter((file) => {
2094
- const relativePath = import_path4.default.relative(scanPath, file);
2219
+ const relativePath = import_path6.default.relative(scanPath, file);
2095
2220
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2096
2221
  });
2097
2222
  if (codeFiles.length === 0) {
2098
- spinner.warn(import_chalk6.default.yellow("No code files found to scan."));
2223
+ spinner.warn(import_chalk7.default.yellow("No code files found to scan."));
2099
2224
  return;
2100
2225
  }
2101
2226
  spinner.text = `Found ${codeFiles.length} files. Scanning...`;
@@ -2104,10 +2229,10 @@ function createScanCommand() {
2104
2229
  const severityCounts = {};
2105
2230
  for (let i = 0; i < codeFiles.length; i++) {
2106
2231
  const filePath = codeFiles[i];
2107
- const relativePath = import_path4.default.relative(scanPath, filePath);
2232
+ const relativePath = import_path6.default.relative(scanPath, filePath);
2108
2233
  spinner.text = `Scanning ${i + 1}/${codeFiles.length}: ${relativePath}`;
2109
2234
  try {
2110
- const content = await import_promises4.default.readFile(filePath, "utf-8");
2235
+ const content = await import_promises5.default.readFile(filePath, "utf-8");
2111
2236
  const response = await import_axios4.default.post(
2112
2237
  `${apiUrl}/api/v1/audit`,
2113
2238
  {
@@ -2143,15 +2268,15 @@ function createScanCommand() {
2143
2268
  }
2144
2269
  } catch (fileError) {
2145
2270
  if (import_axios4.default.isAxiosError(fileError)) {
2146
- console.warn(import_chalk6.default.yellow(`
2271
+ console.warn(import_chalk7.default.yellow(`
2147
2272
  \u26A0\uFE0F Skipping ${relativePath}: ${fileError.message}`));
2148
2273
  } else {
2149
- console.warn(import_chalk6.default.yellow(`
2274
+ console.warn(import_chalk7.default.yellow(`
2150
2275
  \u26A0\uFE0F Error reading ${relativePath}`));
2151
2276
  }
2152
2277
  }
2153
2278
  }
2154
- spinner.succeed(import_chalk6.default.green("\u2705 Scan completed!"));
2279
+ spinner.succeed(import_chalk7.default.green("\u2705 Scan completed!"));
2155
2280
  const aggregatedResponse = {
2156
2281
  results,
2157
2282
  summary: {
@@ -2166,21 +2291,21 @@ function createScanCommand() {
2166
2291
  printPrettyResults(aggregatedResponse);
2167
2292
  }
2168
2293
  } catch (error) {
2169
- spinner.fail(import_chalk6.default.red("\u274C Scan failed"));
2294
+ spinner.fail(import_chalk7.default.red("\u274C Scan failed"));
2170
2295
  if (import_axios4.default.isAxiosError(error)) {
2171
2296
  if (error.response) {
2172
- console.error(import_chalk6.default.red("API Error:"), error.response.data);
2297
+ console.error(import_chalk7.default.red("API Error:"), error.response.data);
2173
2298
  } else if (error.request) {
2174
2299
  console.error(
2175
- import_chalk6.default.red("Network Error:"),
2300
+ import_chalk7.default.red("Network Error:"),
2176
2301
  "Could not reach the API. Is the server running?"
2177
2302
  );
2178
2303
  } else {
2179
- console.error(import_chalk6.default.red("Error:"), error.message);
2304
+ console.error(import_chalk7.default.red("Error:"), error.message);
2180
2305
  }
2181
2306
  } else {
2182
2307
  console.error(
2183
- import_chalk6.default.red("Error:"),
2308
+ import_chalk7.default.red("Error:"),
2184
2309
  error instanceof Error ? error.message : "Unknown error"
2185
2310
  );
2186
2311
  }
@@ -2190,10 +2315,10 @@ function createScanCommand() {
2190
2315
  }
2191
2316
  function printPrettyResults(data) {
2192
2317
  const { results, summary } = data;
2193
- console.log("\n" + import_chalk6.default.bold("\u{1F4CA} Scan Summary"));
2194
- console.log(import_chalk6.default.dim("\u2500".repeat(60)));
2195
- console.log(`Total Files Scanned: ${import_chalk6.default.cyan(summary.total_files)}`);
2196
- console.log(`Total Issues Found: ${import_chalk6.default.yellow(summary.total_issues)}`);
2318
+ console.log("\n" + import_chalk7.default.bold("\u{1F4CA} Scan Summary"));
2319
+ console.log(import_chalk7.default.dim("\u2500".repeat(60)));
2320
+ console.log(`Total Files Scanned: ${import_chalk7.default.cyan(summary.total_files)}`);
2321
+ console.log(`Total Issues Found: ${import_chalk7.default.yellow(summary.total_issues)}`);
2197
2322
  if (summary.by_severity) {
2198
2323
  console.log("\nIssues by Severity:");
2199
2324
  Object.entries(summary.by_severity).forEach(([severity, count]) => {
@@ -2202,51 +2327,51 @@ function printPrettyResults(data) {
2202
2327
  });
2203
2328
  }
2204
2329
  if (results && results.length > 0) {
2205
- console.log("\n" + import_chalk6.default.bold("\u{1F50D} Detailed Results"));
2206
- console.log(import_chalk6.default.dim("\u2500".repeat(60)));
2330
+ console.log("\n" + import_chalk7.default.bold("\u{1F50D} Detailed Results"));
2331
+ console.log(import_chalk7.default.dim("\u2500".repeat(60)));
2207
2332
  results.forEach((result) => {
2208
2333
  if (result.issues && result.issues.length > 0) {
2209
2334
  console.log(`
2210
- ${import_chalk6.default.bold(result.file_path)}`);
2335
+ ${import_chalk7.default.bold(result.file_path)}`);
2211
2336
  result.issues.forEach((issue) => {
2212
2337
  const severityColor = getSeverityColor(issue.severity);
2213
- const lineInfo = issue.line ? import_chalk6.default.dim(`:${issue.line}`) : "";
2338
+ const lineInfo = issue.line ? import_chalk7.default.dim(`:${issue.line}`) : "";
2214
2339
  console.log(
2215
2340
  ` ${severityColor(`[${issue.severity.toUpperCase()}]`)} ${issue.type}${lineInfo}`
2216
2341
  );
2217
- console.log(` ${import_chalk6.default.dim(issue.message)}`);
2342
+ console.log(` ${import_chalk7.default.dim(issue.message)}`);
2218
2343
  });
2219
2344
  }
2220
2345
  });
2221
2346
  }
2222
- console.log("\n" + import_chalk6.default.dim("\u2500".repeat(60)));
2347
+ console.log("\n" + import_chalk7.default.dim("\u2500".repeat(60)));
2223
2348
  }
2224
2349
  function getSeverityColor(severity) {
2225
2350
  switch (severity.toLowerCase()) {
2226
2351
  case "critical":
2227
- return import_chalk6.default.red.bold;
2352
+ return import_chalk7.default.red.bold;
2228
2353
  case "high":
2229
- return import_chalk6.default.red;
2354
+ return import_chalk7.default.red;
2230
2355
  case "medium":
2231
- return import_chalk6.default.yellow;
2356
+ return import_chalk7.default.yellow;
2232
2357
  case "low":
2233
- return import_chalk6.default.blue;
2358
+ return import_chalk7.default.blue;
2234
2359
  case "info":
2235
- return import_chalk6.default.gray;
2360
+ return import_chalk7.default.gray;
2236
2361
  default:
2237
- return import_chalk6.default.white;
2362
+ return import_chalk7.default.white;
2238
2363
  }
2239
2364
  }
2240
2365
 
2241
2366
  // src/commands/fix.ts
2242
2367
  init_cjs_shims();
2243
2368
  var import_commander6 = require("commander");
2244
- var import_chalk7 = __toESM(require("chalk"), 1);
2369
+ var import_chalk8 = __toESM(require("chalk"), 1);
2245
2370
  var import_ora4 = __toESM(require("ora"), 1);
2246
2371
  var import_axios5 = __toESM(require("axios"), 1);
2247
2372
  var import_glob2 = require("glob");
2248
- var import_promises5 = __toESM(require("fs/promises"), 1);
2249
- var import_path5 = __toESM(require("path"), 1);
2373
+ var import_promises6 = __toESM(require("fs/promises"), 1);
2374
+ var import_path7 = __toESM(require("path"), 1);
2250
2375
  var import_inquirer = __toESM(require("inquirer"), 1);
2251
2376
  var Diff = __toESM(require("diff"), 1);
2252
2377
  init_config();
@@ -2258,31 +2383,31 @@ function createFixCommand() {
2258
2383
  const apiUrl = getApiUrl();
2259
2384
  const projectId = options.project || getProjectId();
2260
2385
  if (!projectId) {
2261
- console.log(import_chalk7.default.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2386
+ console.log(import_chalk8.default.yellow("\u26A0\uFE0F Project ID is required for fixing. Using default or pass --project <id>"));
2262
2387
  }
2263
- const scanPath = import_path5.default.resolve(process.cwd(), targetPath);
2388
+ const scanPath = import_path7.default.resolve(process.cwd(), targetPath);
2264
2389
  const gitignorePatterns = await readGitignore(scanPath);
2265
- const pattern = import_path5.default.join(scanPath, "**/*");
2390
+ const pattern = import_path7.default.join(scanPath, "**/*");
2266
2391
  const allFiles = await (0, import_glob2.glob)(pattern, { nodir: true, dot: false, ignore: ["**/node_modules/**", "**/.git/**"] });
2267
2392
  const codeFiles = allFiles.filter((file) => {
2268
- const relativePath = import_path5.default.relative(scanPath, file);
2393
+ const relativePath = import_path7.default.relative(scanPath, file);
2269
2394
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2270
2395
  });
2271
2396
  if (codeFiles.length === 0) {
2272
- console.log(import_chalk7.default.yellow("No code files found."));
2397
+ console.log(import_chalk8.default.yellow("No code files found."));
2273
2398
  return;
2274
2399
  }
2275
- console.log(import_chalk7.default.bold(`
2400
+ console.log(import_chalk8.default.bold(`
2276
2401
  \u{1F9E0} Rigstate Fix Mode`));
2277
- console.log(import_chalk7.default.dim(`Scanning ${codeFiles.length} files with Project Context...
2402
+ console.log(import_chalk8.default.dim(`Scanning ${codeFiles.length} files with Project Context...
2278
2403
  `));
2279
2404
  let fixedCount = 0;
2280
2405
  for (let i = 0; i < codeFiles.length; i++) {
2281
2406
  const filePath = codeFiles[i];
2282
- const relativePath = import_path5.default.relative(scanPath, filePath);
2407
+ const relativePath = import_path7.default.relative(scanPath, filePath);
2283
2408
  spinner.start(`Analyzing ${relativePath}...`);
2284
2409
  try {
2285
- const content = await import_promises5.default.readFile(filePath, "utf-8");
2410
+ const content = await import_promises6.default.readFile(filePath, "utf-8");
2286
2411
  const response = await import_axios5.default.post(
2287
2412
  `${apiUrl}/api/v1/audit`,
2288
2413
  { content, file_path: relativePath, project_id: projectId },
@@ -2293,22 +2418,22 @@ function createFixCommand() {
2293
2418
  if (fixableIssues.length > 0) {
2294
2419
  spinner.stop();
2295
2420
  console.log(`
2296
- ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2421
+ ${import_chalk8.default.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2297
2422
  for (const issue of fixableIssues) {
2298
- console.log(import_chalk7.default.red(`
2423
+ console.log(import_chalk8.default.red(`
2299
2424
  [${issue.type}] ${issue.title}`));
2300
- console.log(import_chalk7.default.dim(issue.suggestion || issue.message));
2425
+ console.log(import_chalk8.default.dim(issue.suggestion || issue.message));
2301
2426
  const diff = Diff.createTwoFilesPatch(relativePath, relativePath, content, issue.fixed_content, "Current", "Fixed");
2302
2427
  console.log("\n" + diff.split("\n").slice(0, 15).join("\n") + (diff.split("\n").length > 15 ? "\n..." : ""));
2303
2428
  const { apply } = await import_inquirer.default.prompt([{
2304
2429
  type: "confirm",
2305
2430
  name: "apply",
2306
- message: `Apply this fix to ${import_chalk7.default.cyan(relativePath)}?`,
2431
+ message: `Apply this fix to ${import_chalk8.default.cyan(relativePath)}?`,
2307
2432
  default: true
2308
2433
  }]);
2309
2434
  if (apply) {
2310
- await import_promises5.default.writeFile(filePath, issue.fixed_content);
2311
- console.log(import_chalk7.default.green(`\u2705 Fixed applied!`));
2435
+ await import_promises6.default.writeFile(filePath, issue.fixed_content);
2436
+ console.log(import_chalk8.default.green(`\u2705 Fixed applied!`));
2312
2437
  fixedCount++;
2313
2438
  if (issue.related_step_id) {
2314
2439
  const { completeStep } = await import_inquirer.default.prompt([{
@@ -2324,15 +2449,15 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2324
2449
  { step_id: issue.related_step_id, status: "COMPLETED", project_id: projectId },
2325
2450
  { headers: { "Authorization": `Bearer ${apiKey}` } }
2326
2451
  );
2327
- console.log(import_chalk7.default.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2452
+ console.log(import_chalk8.default.green(`\u{1F680} Roadmap updated! Mission Control is in sync.`));
2328
2453
  } catch (err) {
2329
- console.error(import_chalk7.default.yellow(`Failed to update roadmap: ${err.message}`));
2454
+ console.error(import_chalk8.default.yellow(`Failed to update roadmap: ${err.message}`));
2330
2455
  }
2331
2456
  }
2332
2457
  }
2333
2458
  break;
2334
2459
  } else {
2335
- console.log(import_chalk7.default.dim("Skipped."));
2460
+ console.log(import_chalk8.default.dim("Skipped."));
2336
2461
  }
2337
2462
  }
2338
2463
  } else {
@@ -2342,11 +2467,11 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2342
2467
  }
2343
2468
  }
2344
2469
  spinner.stop();
2345
- console.log(import_chalk7.default.bold.green(`
2470
+ console.log(import_chalk8.default.bold.green(`
2346
2471
 
2347
2472
  \u{1F680} Fix session complete!`));
2348
2473
  console.log(`Frank fixed ${fixedCount} detected issues.`);
2349
- console.log(import_chalk7.default.dim(`Run 'rigstate scan' to verify remaining issues.`));
2474
+ console.log(import_chalk8.default.dim(`Run 'rigstate scan' to verify remaining issues.`));
2350
2475
  } catch (error) {
2351
2476
  spinner.fail("Fix session failed");
2352
2477
  console.error(error.message);
@@ -2357,12 +2482,12 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2357
2482
  // src/commands/sync.ts
2358
2483
  init_cjs_shims();
2359
2484
  var import_commander7 = require("commander");
2360
- var import_chalk11 = __toESM(require("chalk"), 1);
2485
+ var import_chalk12 = __toESM(require("chalk"), 1);
2361
2486
  var import_ora5 = __toESM(require("ora"), 1);
2362
2487
  init_config();
2363
2488
  var import_axios8 = __toESM(require("axios"), 1);
2364
- var import_promises9 = __toESM(require("fs/promises"), 1);
2365
- var import_path9 = __toESM(require("path"), 1);
2489
+ var import_promises10 = __toESM(require("fs/promises"), 1);
2490
+ var import_path11 = __toESM(require("path"), 1);
2366
2491
  function createSyncCommand() {
2367
2492
  const sync = new import_commander7.Command("sync");
2368
2493
  sync.description("Synchronize local state with Rigstate Cloud").option("-p, --project <id>", "Specify Project ID (saves to config automatically)").action(async (options) => {
@@ -2377,13 +2502,9 @@ function createSyncCommand() {
2377
2502
  }
2378
2503
  let projectId = options.project;
2379
2504
  if (!projectId) {
2380
- try {
2381
- const manifestPath = import_path9.default.join(process.cwd(), ".rigstate");
2382
- const manifestContent = await import_promises9.default.readFile(manifestPath, "utf-8");
2383
- const manifest = JSON.parse(manifestContent);
2384
- if (manifest.project_id) projectId = manifest.project_id;
2385
- } catch (e) {
2386
- }
2505
+ const { loadManifest: loadManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
2506
+ const manifest = await loadManifest2();
2507
+ if (manifest?.project_id) projectId = manifest.project_id;
2387
2508
  }
2388
2509
  if (!projectId) projectId = getProjectId();
2389
2510
  if (options.project) {
@@ -2403,31 +2524,30 @@ function createSyncCommand() {
2403
2524
  }
2404
2525
  const { roadmap, project } = response.data.data;
2405
2526
  const timestamp = response.data.timestamp;
2406
- const targetPath = import_path9.default.join(process.cwd(), "roadmap.json");
2527
+ const targetPath = import_path11.default.join(process.cwd(), "roadmap.json");
2407
2528
  const fileContent = JSON.stringify({
2408
2529
  project,
2409
2530
  last_synced: timestamp,
2410
2531
  roadmap
2411
2532
  }, null, 2);
2412
- await import_promises9.default.writeFile(targetPath, fileContent, "utf-8");
2533
+ await import_promises10.default.writeFile(targetPath, fileContent, "utf-8");
2413
2534
  try {
2414
- const manifestPath = import_path9.default.join(process.cwd(), ".rigstate");
2415
- const manifestContent = {
2535
+ const { saveManifest: saveManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
2536
+ await saveManifest2({
2416
2537
  project_id: projectId,
2417
- project_name: project,
2418
- last_synced: timestamp,
2538
+ linked_at: timestamp,
2539
+ // Using timestamp as linked_at for consistency
2419
2540
  api_url: apiUrl
2420
- };
2421
- await import_promises9.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2541
+ });
2422
2542
  } catch (e) {
2423
2543
  }
2424
- console.log(import_chalk11.default.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2544
+ console.log(import_chalk12.default.bold("\n\u{1F9E0} Agent Skills Provisioning..."));
2425
2545
  try {
2426
2546
  const { provisionSkills: provisionSkills2, generateSkillsDiscoveryBlock: generateSkillsDiscoveryBlock2 } = await Promise.resolve().then(() => (init_skills_provisioner(), skills_provisioner_exports));
2427
2547
  const skills = await provisionSkills2(apiUrl, apiKey, projectId, process.cwd());
2428
- const cursorRulesPath = import_path9.default.join(process.cwd(), ".cursorrules");
2548
+ const cursorRulesPath = import_path11.default.join(process.cwd(), ".cursorrules");
2429
2549
  try {
2430
- let rulesContent = await import_promises9.default.readFile(cursorRulesPath, "utf-8");
2550
+ let rulesContent = await import_promises10.default.readFile(cursorRulesPath, "utf-8");
2431
2551
  const skillsBlock = generateSkillsDiscoveryBlock2(skills);
2432
2552
  if (rulesContent.includes("<available_skills>")) {
2433
2553
  rulesContent = rulesContent.replace(
@@ -2440,17 +2560,17 @@ function createSyncCommand() {
2440
2560
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
2441
2561
  }
2442
2562
  }
2443
- await import_promises9.default.writeFile(cursorRulesPath, rulesContent, "utf-8");
2444
- console.log(import_chalk11.default.dim(` Updated .cursorrules with skills discovery block`));
2563
+ await import_promises10.default.writeFile(cursorRulesPath, rulesContent, "utf-8");
2564
+ console.log(import_chalk12.default.dim(` Updated .cursorrules with skills discovery block`));
2445
2565
  } catch (e) {
2446
2566
  }
2447
2567
  } catch (e) {
2448
- console.log(import_chalk11.default.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2568
+ console.log(import_chalk12.default.yellow(` \u26A0 Skills provisioning skipped: ${e.message}`));
2449
2569
  }
2450
2570
  try {
2451
- const logPath = import_path9.default.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2571
+ const logPath = import_path11.default.join(process.cwd(), ".rigstate", "logs", "last_execution.json");
2452
2572
  try {
2453
- const logContent = await import_promises9.default.readFile(logPath, "utf-8");
2573
+ const logContent = await import_promises10.default.readFile(logPath, "utf-8");
2454
2574
  const logData = JSON.parse(logContent);
2455
2575
  if (logData.task_summary) {
2456
2576
  await import_axios8.default.post(`${apiUrl}/api/v1/execution-logs`, {
@@ -2460,8 +2580,8 @@ function createSyncCommand() {
2460
2580
  }, {
2461
2581
  headers: { Authorization: `Bearer ${apiKey}` }
2462
2582
  });
2463
- await import_promises9.default.unlink(logPath);
2464
- console.log(import_chalk11.default.dim(`\u2714 Mission Report uploaded.`));
2583
+ await import_promises10.default.unlink(logPath);
2584
+ console.log(import_chalk12.default.dim(`\u2714 Mission Report uploaded.`));
2465
2585
  }
2466
2586
  } catch (e) {
2467
2587
  if (e.code !== "ENOENT") {
@@ -2469,12 +2589,12 @@ function createSyncCommand() {
2469
2589
  }
2470
2590
  } catch (e) {
2471
2591
  }
2472
- spinner.succeed(import_chalk11.default.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2473
- console.log(import_chalk11.default.dim(`Local files updated: roadmap.json`));
2592
+ spinner.succeed(import_chalk12.default.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2593
+ console.log(import_chalk12.default.dim(`Local files updated: roadmap.json`));
2474
2594
  const { runGuardianWatchdog: runGuardianWatchdog2 } = await Promise.resolve().then(() => (init_watchdog(), watchdog_exports));
2475
2595
  const settings = response.data.data.settings || {};
2476
2596
  await runGuardianWatchdog2(process.cwd(), settings, projectId);
2477
- console.log(import_chalk11.default.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2597
+ console.log(import_chalk12.default.bold("\n\u{1F4E1} Agent Bridge Heartbeat..."));
2478
2598
  try {
2479
2599
  const bridgeResponse = await import_axios8.default.get(`${apiUrl}/api/v1/agent/bridge`, {
2480
2600
  params: { project_id: projectId },
@@ -2485,10 +2605,10 @@ function createSyncCommand() {
2485
2605
  const pending = tasks.filter((t) => t.status === "PENDING");
2486
2606
  const approved = tasks.filter((t) => t.status === "APPROVED");
2487
2607
  if (pending.length > 0 || approved.length > 0) {
2488
- console.log(import_chalk11.default.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2489
- console.log(import_chalk11.default.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
2608
+ console.log(import_chalk12.default.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2609
+ console.log(import_chalk12.default.dim('Run "rigstate fix" to process these tasks or ensure your IDE MCP server is active.'));
2490
2610
  } else {
2491
- console.log(import_chalk11.default.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2611
+ console.log(import_chalk12.default.green("\u2714 Heartbeat healthy. No pending bridge tasks."));
2492
2612
  }
2493
2613
  const pings = pending.filter((t) => t.proposal?.startsWith("ping"));
2494
2614
  for (const ping of pings) {
@@ -2499,25 +2619,25 @@ function createSyncCommand() {
2499
2619
  }, {
2500
2620
  headers: { Authorization: `Bearer ${apiKey}` }
2501
2621
  });
2502
- console.log(import_chalk11.default.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2622
+ console.log(import_chalk12.default.cyan(`\u{1F3D3} Pong! Acknowledged heartbeat signal [${ping.id}]`));
2503
2623
  }
2504
2624
  }
2505
2625
  } catch (e) {
2506
- console.log(import_chalk11.default.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2626
+ console.log(import_chalk12.default.yellow(`\u26A0 Could not verify Bridge status: ${e.message}`));
2507
2627
  }
2508
2628
  if (options.project) {
2509
- console.log(import_chalk11.default.blue(`Project context saved. Future commands will use this project.`));
2629
+ console.log(import_chalk12.default.blue(`Project context saved. Future commands will use this project.`));
2510
2630
  }
2511
2631
  try {
2512
- const migrationDir = import_path9.default.join(process.cwd(), "supabase", "migrations");
2513
- const files = await import_promises9.default.readdir(migrationDir);
2632
+ const migrationDir = import_path11.default.join(process.cwd(), "supabase", "migrations");
2633
+ const files = await import_promises10.default.readdir(migrationDir);
2514
2634
  const sqlFiles = files.filter((f) => f.endsWith(".sql")).sort();
2515
2635
  if (sqlFiles.length > 0) {
2516
2636
  const latestMigration = sqlFiles[sqlFiles.length - 1];
2517
- console.log(import_chalk11.default.dim(`
2637
+ console.log(import_chalk12.default.dim(`
2518
2638
  \u{1F6E1} Migration Guard:`));
2519
- console.log(import_chalk11.default.dim(` Latest Local: ${latestMigration}`));
2520
- console.log(import_chalk11.default.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
2639
+ console.log(import_chalk12.default.dim(` Latest Local: ${latestMigration}`));
2640
+ console.log(import_chalk12.default.yellow(` \u26A0 Ensure DB schema matches this version. CLI cannot verify Remote RLS policies directly.`));
2521
2641
  }
2522
2642
  } catch (e) {
2523
2643
  }
@@ -2529,15 +2649,15 @@ function createSyncCommand() {
2529
2649
  );
2530
2650
  if (vaultResponse.data.success) {
2531
2651
  const vaultContent = vaultResponse.data.data.content || "";
2532
- const localEnvPath = import_path9.default.join(process.cwd(), ".env.local");
2652
+ const localEnvPath = import_path11.default.join(process.cwd(), ".env.local");
2533
2653
  let localContent = "";
2534
2654
  try {
2535
- localContent = await import_promises9.default.readFile(localEnvPath, "utf-8");
2655
+ localContent = await import_promises10.default.readFile(localEnvPath, "utf-8");
2536
2656
  } catch (e) {
2537
2657
  }
2538
2658
  if (vaultContent.trim() !== localContent.trim()) {
2539
- console.log(import_chalk11.default.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2540
- console.log(import_chalk11.default.yellow(" Status: Drift Detected / Update Available"));
2659
+ console.log(import_chalk12.default.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2660
+ console.log(import_chalk12.default.yellow(" Status: Drift Detected / Update Available"));
2541
2661
  const { syncVault } = await import("inquirer").then((m) => m.default.prompt([{
2542
2662
  type: "confirm",
2543
2663
  name: "syncVault",
@@ -2545,25 +2665,25 @@ function createSyncCommand() {
2545
2665
  default: false
2546
2666
  }]));
2547
2667
  if (syncVault) {
2548
- await import_promises9.default.writeFile(localEnvPath, vaultContent, "utf-8");
2549
- console.log(import_chalk11.default.green(" \u2705 .env.local synchronized with Vault."));
2668
+ await import_promises10.default.writeFile(localEnvPath, vaultContent, "utf-8");
2669
+ console.log(import_chalk12.default.green(" \u2705 .env.local synchronized with Vault."));
2550
2670
  } else {
2551
- console.log(import_chalk11.default.dim(" Skipped vault sync."));
2671
+ console.log(import_chalk12.default.dim(" Skipped vault sync."));
2552
2672
  }
2553
2673
  } else {
2554
- console.log(import_chalk11.default.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2674
+ console.log(import_chalk12.default.dim("\n\u{1F510} Sovereign Foundation: Synced."));
2555
2675
  }
2556
2676
  }
2557
2677
  } catch (e) {
2558
2678
  }
2559
- console.log(import_chalk11.default.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2679
+ console.log(import_chalk12.default.dim("\n\u{1F6E1}\uFE0F System Integrity Check..."));
2560
2680
  await checkSystemIntegrity(apiUrl, apiKey, projectId);
2561
2681
  } catch (error) {
2562
2682
  if (import_axios8.default.isAxiosError(error)) {
2563
2683
  const message = error.response?.data?.error || error.message;
2564
- spinner.fail(import_chalk11.default.red(`Sync failed: ${message}`));
2684
+ spinner.fail(import_chalk12.default.red(`Sync failed: ${message}`));
2565
2685
  } else {
2566
- spinner.fail(import_chalk11.default.red("Sync failed: " + (error.message || "Unknown error")));
2686
+ spinner.fail(import_chalk12.default.red("Sync failed: " + (error.message || "Unknown error")));
2567
2687
  }
2568
2688
  }
2569
2689
  });
@@ -2579,64 +2699,49 @@ async function checkSystemIntegrity(apiUrl, apiKey, projectId) {
2579
2699
  const { migrations, rls, guardian_violations } = response.data.data;
2580
2700
  if (migrations) {
2581
2701
  if (migrations.in_sync) {
2582
- console.log(import_chalk11.default.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2702
+ console.log(import_chalk12.default.green(` \u2705 Migrations synced (${migrations.count} versions)`));
2583
2703
  } else {
2584
- console.log(import_chalk11.default.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2704
+ console.log(import_chalk12.default.red(` \u{1F6D1} CRITICAL: DB Schema out of sync! ${migrations.missing?.length || 0} migrations not applied.`));
2585
2705
  if (migrations.missing?.length > 0) {
2586
- console.log(import_chalk11.default.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2706
+ console.log(import_chalk12.default.dim(` Missing: ${migrations.missing.slice(0, 3).join(", ")}${migrations.missing.length > 3 ? "..." : ""}`));
2587
2707
  }
2588
- console.log(import_chalk11.default.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2708
+ console.log(import_chalk12.default.yellow(` Run 'supabase db push' or apply migrations immediately.`));
2589
2709
  }
2590
2710
  }
2591
2711
  if (rls) {
2592
2712
  if (rls.all_secured) {
2593
- console.log(import_chalk11.default.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2713
+ console.log(import_chalk12.default.green(` \u2705 RLS Audit Passed (${rls.table_count} tables secured)`));
2594
2714
  } else {
2595
- console.log(import_chalk11.default.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2715
+ console.log(import_chalk12.default.red(` \u{1F6D1} CRITICAL: Security Vulnerability! ${rls.unsecured?.length || 0} tables have RLS disabled.`));
2596
2716
  rls.unsecured?.forEach((table) => {
2597
- console.log(import_chalk11.default.red(` - ${table}`));
2717
+ console.log(import_chalk12.default.red(` - ${table}`));
2598
2718
  });
2599
- console.log(import_chalk11.default.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2719
+ console.log(import_chalk12.default.yellow(' Enable RLS immediately: ALTER TABLE "table" ENABLE ROW LEVEL SECURITY;'));
2600
2720
  }
2601
2721
  }
2602
2722
  if (guardian_violations) {
2603
2723
  if (guardian_violations.count === 0) {
2604
- console.log(import_chalk11.default.green(" \u2705 Guardian: No active violations"));
2724
+ console.log(import_chalk12.default.green(" \u2705 Guardian: No active violations"));
2605
2725
  } else {
2606
- console.log(import_chalk11.default.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2607
- console.log(import_chalk11.default.dim(' Run "rigstate check" for details.'));
2726
+ console.log(import_chalk12.default.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2727
+ console.log(import_chalk12.default.dim(' Run "rigstate check" for details.'));
2608
2728
  }
2609
2729
  }
2610
2730
  }
2611
2731
  } catch (e) {
2612
- console.log(import_chalk11.default.dim(" (System integrity check skipped - API endpoint not available)"));
2732
+ console.log(import_chalk12.default.dim(" (System integrity check skipped - API endpoint not available)"));
2613
2733
  }
2614
2734
  }
2615
2735
 
2616
2736
  // src/commands/init.ts
2617
2737
  init_cjs_shims();
2618
2738
  var import_commander8 = require("commander");
2619
- var import_chalk12 = __toESM(require("chalk"), 1);
2739
+ var import_chalk13 = __toESM(require("chalk"), 1);
2620
2740
  var import_promises11 = __toESM(require("fs/promises"), 1);
2621
- var import_path11 = __toESM(require("path"), 1);
2741
+ var import_path12 = __toESM(require("path"), 1);
2622
2742
  var import_ora6 = __toESM(require("ora"), 1);
2623
2743
  var import_child_process = require("child_process");
2624
-
2625
- // src/utils/manifest.ts
2626
- init_cjs_shims();
2627
- var import_promises10 = __toESM(require("fs/promises"), 1);
2628
- var import_path10 = __toESM(require("path"), 1);
2629
- async function loadManifest() {
2630
- try {
2631
- const manifestPath = import_path10.default.join(process.cwd(), ".rigstate");
2632
- const content = await import_promises10.default.readFile(manifestPath, "utf-8");
2633
- return JSON.parse(content);
2634
- } catch {
2635
- return null;
2636
- }
2637
- }
2638
-
2639
- // src/commands/init.ts
2744
+ init_manifest();
2640
2745
  init_config();
2641
2746
  var import_axios9 = __toESM(require("axios"), 1);
2642
2747
  function createInitCommand() {
@@ -2646,7 +2751,7 @@ function createInitCommand() {
2646
2751
  try {
2647
2752
  apiKey = getApiKey();
2648
2753
  } catch (e) {
2649
- spinner.fail(import_chalk12.default.red('Not authenticated. Run "rigstate login" first.'));
2754
+ spinner.fail(import_chalk13.default.red('Not authenticated. Run "rigstate login" first.'));
2650
2755
  return;
2651
2756
  }
2652
2757
  const apiUrl = getApiUrl();
@@ -2743,7 +2848,7 @@ function createInitCommand() {
2743
2848
  selectedOrgId = orgId;
2744
2849
  }
2745
2850
  if (!selectedOrgId) {
2746
- console.log(import_chalk12.default.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2851
+ console.log(import_chalk13.default.yellow("No organization available. Please create the project via the Rigstate dashboard."));
2747
2852
  return;
2748
2853
  }
2749
2854
  spinner.start("Creating new project...");
@@ -2755,13 +2860,13 @@ function createInitCommand() {
2755
2860
  headers: { Authorization: `Bearer ${apiKey}` }
2756
2861
  });
2757
2862
  if (!createResponse.data.success) {
2758
- spinner.fail(import_chalk12.default.red("Failed to create project: " + createResponse.data.error));
2863
+ spinner.fail(import_chalk13.default.red("Failed to create project: " + createResponse.data.error));
2759
2864
  return;
2760
2865
  }
2761
2866
  projectId = createResponse.data.data.project.id;
2762
- spinner.succeed(import_chalk12.default.green(`Created new project: ${newName}`));
2867
+ spinner.succeed(import_chalk13.default.green(`Created new project: ${newName}`));
2763
2868
  } catch (e) {
2764
- spinner.fail(import_chalk12.default.red("Project creation API not available. Please create via dashboard."));
2869
+ spinner.fail(import_chalk13.default.red("Project creation API not available. Please create via dashboard."));
2765
2870
  return;
2766
2871
  }
2767
2872
  } else {
@@ -2771,28 +2876,27 @@ function createInitCommand() {
2771
2876
  spinner.start(`Linking to project ID: ${projectId}...`);
2772
2877
  }
2773
2878
  setProjectId(projectId);
2774
- const manifestPath = import_path11.default.join(process.cwd(), ".rigstate");
2775
- const manifestContent = {
2879
+ const { saveManifest: saveManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
2880
+ await saveManifest2({
2776
2881
  project_id: projectId,
2777
- last_linked: (/* @__PURE__ */ new Date()).toISOString(),
2882
+ linked_at: (/* @__PURE__ */ new Date()).toISOString(),
2778
2883
  api_url: apiUrl
2779
- };
2780
- await import_promises11.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2884
+ });
2781
2885
  try {
2782
2886
  await import_promises11.default.access(".git");
2783
2887
  } catch {
2784
2888
  spinner.text = "Initializing git repository...";
2785
2889
  (0, import_child_process.execSync)("git init", { stdio: "ignore" });
2786
2890
  }
2787
- spinner.succeed(import_chalk12.default.green(`\u2705 Linked to project: ${projectId}`));
2891
+ spinner.succeed(import_chalk13.default.green(`\u2705 Linked to project: ${projectId}`));
2788
2892
  await generateRules(apiUrl, apiKey, projectId, options.force, spinner);
2789
2893
  console.log("");
2790
- console.log(import_chalk12.default.blue("Next steps:"));
2791
- console.log(import_chalk12.default.dim(" rigstate sync - Sync roadmap and context"));
2792
- console.log(import_chalk12.default.dim(" rigstate watch - Start development loop"));
2793
- console.log(import_chalk12.default.dim(" rigstate focus - Get current task"));
2894
+ console.log(import_chalk13.default.blue("Next steps:"));
2895
+ console.log(import_chalk13.default.dim(" rigstate sync - Sync roadmap and context"));
2896
+ console.log(import_chalk13.default.dim(" rigstate watch - Start development loop"));
2897
+ console.log(import_chalk13.default.dim(" rigstate focus - Get current task"));
2794
2898
  } catch (e) {
2795
- spinner.fail(import_chalk12.default.red("Initialization failed: " + e.message));
2899
+ spinner.fail(import_chalk13.default.red("Initialization failed: " + e.message));
2796
2900
  }
2797
2901
  });
2798
2902
  }
@@ -2807,19 +2911,19 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
2807
2911
  if (response.data.success || response.data.files) {
2808
2912
  const files = response.data.files || [];
2809
2913
  if (files.length === 0 && response.data.rules) {
2810
- const rulesPath = import_path11.default.join(process.cwd(), ".cursorrules");
2914
+ const rulesPath = import_path12.default.join(process.cwd(), ".cursorrules");
2811
2915
  await import_promises11.default.writeFile(rulesPath, response.data.rules, "utf-8");
2812
- spinner.succeed(import_chalk12.default.green("\u2714 Generated .cursorrules (legacy mode)"));
2916
+ spinner.succeed(import_chalk13.default.green("\u2714 Generated .cursorrules (legacy mode)"));
2813
2917
  return;
2814
2918
  }
2815
2919
  for (const file of files) {
2816
- const targetPath = import_path11.default.join(process.cwd(), file.path);
2817
- const targetDir = import_path11.default.dirname(targetPath);
2920
+ const targetPath = import_path12.default.join(process.cwd(), file.path);
2921
+ const targetDir = import_path12.default.dirname(targetPath);
2818
2922
  await import_promises11.default.mkdir(targetDir, { recursive: true });
2819
2923
  try {
2820
2924
  await import_promises11.default.access(targetPath);
2821
2925
  if (!force && !file.path.startsWith(".cursor/rules/")) {
2822
- console.log(import_chalk12.default.dim(` ${file.path} already exists. Skipping.`));
2926
+ console.log(import_chalk13.default.dim(` ${file.path} already exists. Skipping.`));
2823
2927
  continue;
2824
2928
  }
2825
2929
  } catch {
@@ -2827,45 +2931,46 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
2827
2931
  await import_promises11.default.writeFile(targetPath, file.content, "utf-8");
2828
2932
  }
2829
2933
  if (files.length > 0) {
2830
- const legacyPath = import_path11.default.join(process.cwd(), ".cursorrules");
2934
+ const legacyPath = import_path12.default.join(process.cwd(), ".cursorrules");
2831
2935
  try {
2832
2936
  const stats = await import_promises11.default.stat(legacyPath);
2833
2937
  if (stats.isFile()) {
2834
2938
  await import_promises11.default.rename(legacyPath, `${legacyPath}.bak`);
2835
- console.log(import_chalk12.default.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2939
+ console.log(import_chalk13.default.dim(" Moved legacy .cursorrules to .cursorrules.bak"));
2836
2940
  }
2837
2941
  } catch (e) {
2838
2942
  }
2839
2943
  }
2840
- spinner.succeed(import_chalk12.default.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2944
+ spinner.succeed(import_chalk13.default.green(`\u2714 Generated ${files.length} rule files (v${response.data.version || "3.0"})`));
2841
2945
  } else {
2842
- spinner.info(import_chalk12.default.dim(" Rules generation skipped (API response invalid)"));
2946
+ spinner.info(import_chalk13.default.dim(" Rules generation skipped (API response invalid)"));
2843
2947
  }
2844
2948
  } catch (e) {
2845
- spinner.info(import_chalk12.default.dim(` Rules generation failed: ${e.message}`));
2949
+ spinner.info(import_chalk13.default.dim(` Rules generation failed: ${e.message}`));
2846
2950
  }
2847
2951
  }
2848
2952
 
2849
2953
  // src/commands/check.ts
2850
2954
  init_cjs_shims();
2851
2955
  var import_commander9 = require("commander");
2852
- var import_chalk14 = __toESM(require("chalk"), 1);
2956
+ var import_chalk15 = __toESM(require("chalk"), 1);
2853
2957
  var import_ora7 = __toESM(require("ora"), 1);
2854
2958
  var import_axios10 = __toESM(require("axios"), 1);
2855
2959
  var import_glob3 = require("glob");
2856
2960
  var import_promises13 = __toESM(require("fs/promises"), 1);
2857
- var import_path13 = __toESM(require("path"), 1);
2961
+ var import_path14 = __toESM(require("path"), 1);
2858
2962
  var import_child_process2 = require("child_process");
2859
2963
  init_config();
2964
+ init_manifest();
2860
2965
 
2861
2966
  // src/utils/rule-engine.ts
2862
2967
  init_cjs_shims();
2863
2968
  var import_promises12 = __toESM(require("fs/promises"), 1);
2864
- var import_path12 = __toESM(require("path"), 1);
2865
- var import_chalk13 = __toESM(require("chalk"), 1);
2969
+ var import_path13 = __toESM(require("path"), 1);
2970
+ var import_chalk14 = __toESM(require("chalk"), 1);
2866
2971
  async function checkFile(filePath, rules, rootPath) {
2867
2972
  const violations = [];
2868
- const relativePath = import_path12.default.relative(rootPath, filePath);
2973
+ const relativePath = import_path13.default.relative(rootPath, filePath);
2869
2974
  try {
2870
2975
  const content = await import_promises12.default.readFile(filePath, "utf-8");
2871
2976
  const lines = content.split("\n");
@@ -2958,7 +3063,7 @@ async function evaluateRule(rule, content, lines, filePath) {
2958
3063
  case "NAMING_CONVENTION": {
2959
3064
  const value = rule.value;
2960
3065
  const pattern = new RegExp(value.pattern);
2961
- const fileName = import_path12.default.basename(filePath);
3066
+ const fileName = import_path13.default.basename(filePath);
2962
3067
  if (filePath.includes(value.context) && !pattern.test(fileName)) {
2963
3068
  violations.push({
2964
3069
  file: filePath,
@@ -3017,12 +3122,12 @@ function checkFunctionLines(content, lines, filePath, rule, limit) {
3017
3122
  }
3018
3123
  function formatViolations(violations) {
3019
3124
  for (const v of violations) {
3020
- const severityColor = v.severity === "critical" ? import_chalk13.default.red : v.severity === "warning" ? import_chalk13.default.yellow : import_chalk13.default.blue;
3021
- const lineInfo = v.line ? import_chalk13.default.dim(`:${v.line}`) : "";
3125
+ const severityColor = v.severity === "critical" ? import_chalk14.default.red : v.severity === "warning" ? import_chalk14.default.yellow : import_chalk14.default.blue;
3126
+ const lineInfo = v.line ? import_chalk14.default.dim(`:${v.line}`) : "";
3022
3127
  console.log(` ${severityColor(`[${v.severity.toUpperCase()}]`)} ${v.file}${lineInfo}`);
3023
3128
  console.log(` ${v.message}`);
3024
3129
  if (v.details) {
3025
- console.log(` ${import_chalk13.default.dim(v.details)}`);
3130
+ console.log(` ${import_chalk14.default.dim(v.details)}`);
3026
3131
  }
3027
3132
  }
3028
3133
  }
@@ -3067,15 +3172,15 @@ function createCheckCommand() {
3067
3172
  projectId = getProjectId();
3068
3173
  }
3069
3174
  if (!projectId) {
3070
- console.log(import_chalk14.default.red("\u274C No project context found."));
3071
- console.log(import_chalk14.default.dim(' Run "rigstate link" or pass --project <id>'));
3175
+ console.log(import_chalk15.default.red("\u274C No project context found."));
3176
+ console.log(import_chalk15.default.dim(' Run "rigstate link" or pass --project <id>'));
3072
3177
  process.exit(2);
3073
3178
  }
3074
3179
  let apiKey;
3075
3180
  try {
3076
3181
  apiKey = getApiKey();
3077
3182
  } catch {
3078
- console.log(import_chalk14.default.red('\u274C Not authenticated. Run "rigstate login" first.'));
3183
+ console.log(import_chalk15.default.red('\u274C Not authenticated. Run "rigstate login" first.'));
3079
3184
  process.exit(2);
3080
3185
  }
3081
3186
  spinner.start("Fetching Guardian rules...");
@@ -3103,17 +3208,17 @@ function createCheckCommand() {
3103
3208
  } catch (apiError) {
3104
3209
  const cached = await loadCachedRules(projectId);
3105
3210
  if (cached && !isStale(cached.timestamp, CACHE_MAX_AGE_MS)) {
3106
- spinner.warn(import_chalk14.default.yellow("Using cached rules (API unavailable)"));
3211
+ spinner.warn(import_chalk15.default.yellow("Using cached rules (API unavailable)"));
3107
3212
  rules = cached.rules;
3108
3213
  settings = cached.settings;
3109
3214
  } else {
3110
- spinner.fail(import_chalk14.default.red("Failed to fetch rules and no valid cache"));
3111
- console.log(import_chalk14.default.dim(` Error: ${apiError.message}`));
3215
+ spinner.fail(import_chalk15.default.red("Failed to fetch rules and no valid cache"));
3216
+ console.log(import_chalk15.default.dim(` Error: ${apiError.message}`));
3112
3217
  process.exit(2);
3113
3218
  }
3114
3219
  }
3115
3220
  spinner.succeed(`Loaded ${rules.length} Guardian rules`);
3116
- const scanPath = import_path13.default.resolve(process.cwd(), targetPath);
3221
+ const scanPath = import_path14.default.resolve(process.cwd(), targetPath);
3117
3222
  let filesToCheck;
3118
3223
  if (options.staged) {
3119
3224
  spinner.start("Getting staged files...");
@@ -3122,14 +3227,14 @@ function createCheckCommand() {
3122
3227
  encoding: "utf-8",
3123
3228
  cwd: process.cwd()
3124
3229
  });
3125
- filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => import_path13.default.resolve(process.cwd(), f));
3230
+ filesToCheck = stagedOutput.split("\n").filter((f) => f.trim()).filter((f) => isCodeFile2(f)).map((f) => import_path14.default.resolve(process.cwd(), f));
3126
3231
  } catch {
3127
3232
  spinner.fail("Not a git repository or no staged files");
3128
3233
  process.exit(2);
3129
3234
  }
3130
3235
  } else {
3131
- spinner.start(`Scanning ${import_chalk14.default.cyan(targetPath)}...`);
3132
- const pattern = import_path13.default.join(scanPath, "**/*");
3236
+ spinner.start(`Scanning ${import_chalk15.default.cyan(targetPath)}...`);
3237
+ const pattern = import_path14.default.join(scanPath, "**/*");
3133
3238
  const allFiles = await (0, import_glob3.glob)(pattern, {
3134
3239
  nodir: true,
3135
3240
  dot: false,
@@ -3145,7 +3250,7 @@ function createCheckCommand() {
3145
3250
  filesToCheck = allFiles.filter((f) => isCodeFile2(f));
3146
3251
  }
3147
3252
  if (filesToCheck.length === 0) {
3148
- spinner.warn(import_chalk14.default.yellow("No code files found to check."));
3253
+ spinner.warn(import_chalk15.default.yellow("No code files found to check."));
3149
3254
  outputResults([], !!options.json);
3150
3255
  process.exit(0);
3151
3256
  }
@@ -3154,7 +3259,7 @@ function createCheckCommand() {
3154
3259
  const results = [];
3155
3260
  for (let i = 0; i < filesToCheck.length; i++) {
3156
3261
  const file = filesToCheck[i];
3157
- spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${import_path13.default.basename(file)}`;
3262
+ spinner.text = `Checking ${i + 1}/${filesToCheck.length}: ${import_path14.default.basename(file)}`;
3158
3263
  const result = await checkFile(file, rules, process.cwd());
3159
3264
  results.push(result);
3160
3265
  }
@@ -3164,46 +3269,46 @@ function createCheckCommand() {
3164
3269
  outputResults(results, true);
3165
3270
  } else {
3166
3271
  outputResults(results, false);
3167
- console.log("\n" + import_chalk14.default.bold("\u{1F4CA} Summary"));
3168
- console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3169
- console.log(`Files checked: ${import_chalk14.default.cyan(summary.totalFiles)}`);
3170
- console.log(`Total violations: ${summary.totalViolations > 0 ? import_chalk14.default.red(summary.totalViolations) : import_chalk14.default.green(0)}`);
3272
+ console.log("\n" + import_chalk15.default.bold("\u{1F4CA} Summary"));
3273
+ console.log(import_chalk15.default.dim("\u2500".repeat(50)));
3274
+ console.log(`Files checked: ${import_chalk15.default.cyan(summary.totalFiles)}`);
3275
+ console.log(`Total violations: ${summary.totalViolations > 0 ? import_chalk15.default.red(summary.totalViolations) : import_chalk15.default.green(0)}`);
3171
3276
  if (summary.totalViolations > 0) {
3172
- console.log(` ${import_chalk14.default.red("Critical:")} ${summary.criticalCount}`);
3173
- console.log(` ${import_chalk14.default.yellow("Warning:")} ${summary.warningCount}`);
3174
- console.log(` ${import_chalk14.default.blue("Info:")} ${summary.infoCount}`);
3277
+ console.log(` ${import_chalk15.default.red("Critical:")} ${summary.criticalCount}`);
3278
+ console.log(` ${import_chalk15.default.yellow("Warning:")} ${summary.warningCount}`);
3279
+ console.log(` ${import_chalk15.default.blue("Info:")} ${summary.infoCount}`);
3175
3280
  }
3176
- console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3281
+ console.log(import_chalk15.default.dim("\u2500".repeat(50)));
3177
3282
  }
3178
3283
  if (options.strict !== void 0) {
3179
3284
  const strictLevel = typeof options.strict === "string" ? options.strict : "all";
3180
3285
  if (strictLevel === "critical" && summary.criticalCount > 0) {
3181
- console.log(import_chalk14.default.red("\n\u274C Check failed: Critical violations found"));
3286
+ console.log(import_chalk15.default.red("\n\u274C Check failed: Critical violations found"));
3182
3287
  process.exit(1);
3183
3288
  } else if (strictLevel === "all" && summary.totalViolations > 0) {
3184
- console.log(import_chalk14.default.red("\n\u274C Check failed: Violations found"));
3289
+ console.log(import_chalk15.default.red("\n\u274C Check failed: Violations found"));
3185
3290
  process.exit(1);
3186
3291
  }
3187
3292
  }
3188
3293
  if (summary.totalViolations === 0) {
3189
- console.log(import_chalk14.default.green("\n\u2705 All checks passed!"));
3294
+ console.log(import_chalk15.default.green("\n\u2705 All checks passed!"));
3190
3295
  }
3191
3296
  process.exit(0);
3192
3297
  } catch (error) {
3193
- spinner.fail(import_chalk14.default.red("Check failed"));
3194
- console.error(import_chalk14.default.red("Error:"), error.message);
3298
+ spinner.fail(import_chalk15.default.red("Check failed"));
3299
+ console.error(import_chalk15.default.red("Error:"), error.message);
3195
3300
  process.exit(2);
3196
3301
  }
3197
3302
  });
3198
3303
  }
3199
3304
  function isCodeFile2(filePath) {
3200
3305
  const codeExtensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3201
- const ext = import_path13.default.extname(filePath).toLowerCase();
3306
+ const ext = import_path14.default.extname(filePath).toLowerCase();
3202
3307
  return codeExtensions.includes(ext);
3203
3308
  }
3204
3309
  async function loadCachedRules(projectId) {
3205
3310
  try {
3206
- const cachePath = import_path13.default.join(process.cwd(), CACHE_FILE2);
3311
+ const cachePath = import_path14.default.join(process.cwd(), CACHE_FILE2);
3207
3312
  const content = await import_promises13.default.readFile(cachePath, "utf-8");
3208
3313
  const cached = JSON.parse(content);
3209
3314
  if (cached.projectId !== projectId) {
@@ -3216,7 +3321,7 @@ async function loadCachedRules(projectId) {
3216
3321
  }
3217
3322
  async function saveCachedRules(projectId, rules, settings) {
3218
3323
  try {
3219
- const cacheDir = import_path13.default.join(process.cwd(), ".rigstate");
3324
+ const cacheDir = import_path14.default.join(process.cwd(), ".rigstate");
3220
3325
  await import_promises13.default.mkdir(cacheDir, { recursive: true });
3221
3326
  const cached = {
3222
3327
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3225,7 +3330,7 @@ async function saveCachedRules(projectId, rules, settings) {
3225
3330
  settings
3226
3331
  };
3227
3332
  await import_promises13.default.writeFile(
3228
- import_path13.default.join(cacheDir, "rules-cache.json"),
3333
+ import_path14.default.join(cacheDir, "rules-cache.json"),
3229
3334
  JSON.stringify(cached, null, 2)
3230
3335
  );
3231
3336
  } catch {
@@ -3247,8 +3352,8 @@ function outputResults(results, json) {
3247
3352
  if (!hasViolations) {
3248
3353
  return;
3249
3354
  }
3250
- console.log("\n" + import_chalk14.default.bold("\u{1F50D} Violations Found"));
3251
- console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3355
+ console.log("\n" + import_chalk15.default.bold("\u{1F50D} Violations Found"));
3356
+ console.log(import_chalk15.default.dim("\u2500".repeat(50)));
3252
3357
  for (const result of results) {
3253
3358
  if (result.violations.length > 0) {
3254
3359
  formatViolations(result.violations);
@@ -3259,9 +3364,9 @@ function outputResults(results, json) {
3259
3364
  // src/commands/hooks.ts
3260
3365
  init_cjs_shims();
3261
3366
  var import_commander10 = require("commander");
3262
- var import_chalk15 = __toESM(require("chalk"), 1);
3367
+ var import_chalk16 = __toESM(require("chalk"), 1);
3263
3368
  var import_promises14 = __toESM(require("fs/promises"), 1);
3264
- var import_path14 = __toESM(require("path"), 1);
3369
+ var import_path15 = __toESM(require("path"), 1);
3265
3370
  var PRE_COMMIT_SCRIPT = `#!/bin/sh
3266
3371
  # Rigstate Guardian Pre-commit Hook
3267
3372
  # Installed by: rigstate hooks install
@@ -3290,23 +3395,23 @@ function createHooksCommand() {
3290
3395
  const hooks = new import_commander10.Command("hooks").description("Manage git hooks for Guardian integration");
3291
3396
  hooks.command("install").description("Install pre-commit hook to run Guardian checks").option("--strict [level]", 'Strict level: "all" or "critical" (default)', "critical").action(async (options) => {
3292
3397
  try {
3293
- const gitDir = import_path14.default.join(process.cwd(), ".git");
3398
+ const gitDir = import_path15.default.join(process.cwd(), ".git");
3294
3399
  try {
3295
3400
  await import_promises14.default.access(gitDir);
3296
3401
  } catch {
3297
- console.log(import_chalk15.default.red("\u274C Not a git repository."));
3298
- console.log(import_chalk15.default.dim(' Initialize with "git init" first.'));
3402
+ console.log(import_chalk16.default.red("\u274C Not a git repository."));
3403
+ console.log(import_chalk16.default.dim(' Initialize with "git init" first.'));
3299
3404
  process.exit(1);
3300
3405
  }
3301
- const hooksDir = import_path14.default.join(gitDir, "hooks");
3406
+ const hooksDir = import_path15.default.join(gitDir, "hooks");
3302
3407
  await import_promises14.default.mkdir(hooksDir, { recursive: true });
3303
- const preCommitPath = import_path14.default.join(hooksDir, "pre-commit");
3408
+ const preCommitPath = import_path15.default.join(hooksDir, "pre-commit");
3304
3409
  let existingContent = "";
3305
3410
  try {
3306
3411
  existingContent = await import_promises14.default.readFile(preCommitPath, "utf-8");
3307
3412
  if (existingContent.includes("rigstate")) {
3308
- console.log(import_chalk15.default.yellow("\u26A0 Rigstate pre-commit hook already installed."));
3309
- console.log(import_chalk15.default.dim(' Use "rigstate hooks uninstall" to remove first.'));
3413
+ console.log(import_chalk16.default.yellow("\u26A0 Rigstate pre-commit hook already installed."));
3414
+ console.log(import_chalk16.default.dim(' Use "rigstate hooks uninstall" to remove first.'));
3310
3415
  return;
3311
3416
  }
3312
3417
  } catch {
@@ -3318,33 +3423,33 @@ function createHooksCommand() {
3318
3423
  if (existingContent && !existingContent.includes("rigstate")) {
3319
3424
  const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
3320
3425
  await import_promises14.default.writeFile(preCommitPath, combinedScript, { mode: 493 });
3321
- console.log(import_chalk15.default.green("\u2705 Rigstate hook appended to existing pre-commit."));
3426
+ console.log(import_chalk16.default.green("\u2705 Rigstate hook appended to existing pre-commit."));
3322
3427
  } else {
3323
3428
  await import_promises14.default.writeFile(preCommitPath, script, { mode: 493 });
3324
- console.log(import_chalk15.default.green("\u2705 Pre-commit hook installed!"));
3429
+ console.log(import_chalk16.default.green("\u2705 Pre-commit hook installed!"));
3325
3430
  }
3326
- console.log(import_chalk15.default.dim(` Path: ${preCommitPath}`));
3327
- console.log(import_chalk15.default.dim(` Strict level: ${options.strict}`));
3431
+ console.log(import_chalk16.default.dim(` Path: ${preCommitPath}`));
3432
+ console.log(import_chalk16.default.dim(` Strict level: ${options.strict}`));
3328
3433
  console.log("");
3329
- console.log(import_chalk15.default.cyan("Guardian will now check your code before each commit."));
3330
- console.log(import_chalk15.default.dim('Use "rigstate hooks uninstall" to remove the hook.'));
3434
+ console.log(import_chalk16.default.cyan("Guardian will now check your code before each commit."));
3435
+ console.log(import_chalk16.default.dim('Use "rigstate hooks uninstall" to remove the hook.'));
3331
3436
  } catch (error) {
3332
- console.error(import_chalk15.default.red("Failed to install hook:"), error.message);
3437
+ console.error(import_chalk16.default.red("Failed to install hook:"), error.message);
3333
3438
  process.exit(1);
3334
3439
  }
3335
3440
  });
3336
3441
  hooks.command("uninstall").description("Remove Rigstate pre-commit hook").action(async () => {
3337
3442
  try {
3338
- const preCommitPath = import_path14.default.join(process.cwd(), ".git", "hooks", "pre-commit");
3443
+ const preCommitPath = import_path15.default.join(process.cwd(), ".git", "hooks", "pre-commit");
3339
3444
  try {
3340
3445
  const content = await import_promises14.default.readFile(preCommitPath, "utf-8");
3341
3446
  if (!content.includes("rigstate")) {
3342
- console.log(import_chalk15.default.yellow("\u26A0 No Rigstate hook found in pre-commit."));
3447
+ console.log(import_chalk16.default.yellow("\u26A0 No Rigstate hook found in pre-commit."));
3343
3448
  return;
3344
3449
  }
3345
3450
  if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
3346
3451
  await import_promises14.default.unlink(preCommitPath);
3347
- console.log(import_chalk15.default.green("\u2705 Pre-commit hook removed."));
3452
+ console.log(import_chalk16.default.green("\u2705 Pre-commit hook removed."));
3348
3453
  } else {
3349
3454
  const lines = content.split("\n");
3350
3455
  const filteredLines = [];
@@ -3363,13 +3468,13 @@ function createHooksCommand() {
3363
3468
  }
3364
3469
  }
3365
3470
  await import_promises14.default.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
3366
- console.log(import_chalk15.default.green("\u2705 Rigstate section removed from pre-commit hook."));
3471
+ console.log(import_chalk16.default.green("\u2705 Rigstate section removed from pre-commit hook."));
3367
3472
  }
3368
3473
  } catch {
3369
- console.log(import_chalk15.default.yellow("\u26A0 No pre-commit hook found."));
3474
+ console.log(import_chalk16.default.yellow("\u26A0 No pre-commit hook found."));
3370
3475
  }
3371
3476
  } catch (error) {
3372
- console.error(import_chalk15.default.red("Failed to uninstall hook:"), error.message);
3477
+ console.error(import_chalk16.default.red("Failed to uninstall hook:"), error.message);
3373
3478
  process.exit(1);
3374
3479
  }
3375
3480
  });
@@ -3379,40 +3484,40 @@ function createHooksCommand() {
3379
3484
  // src/commands/daemon.ts
3380
3485
  init_cjs_shims();
3381
3486
  var import_commander11 = require("commander");
3382
- var import_chalk21 = __toESM(require("chalk"), 1);
3487
+ var import_chalk22 = __toESM(require("chalk"), 1);
3383
3488
  var import_ora8 = __toESM(require("ora"), 1);
3384
3489
  var import_promises19 = __toESM(require("fs/promises"), 1);
3385
- var import_path22 = __toESM(require("path"), 1);
3490
+ var import_path23 = __toESM(require("path"), 1);
3386
3491
 
3387
3492
  // src/daemon/factory.ts
3388
3493
  init_cjs_shims();
3389
3494
 
3390
3495
  // src/daemon/core.ts
3391
3496
  init_cjs_shims();
3392
- var import_chalk19 = __toESM(require("chalk"), 1);
3393
- var fs18 = __toESM(require("fs/promises"), 1);
3394
- var import_path20 = __toESM(require("path"), 1);
3497
+ var import_chalk20 = __toESM(require("chalk"), 1);
3498
+ var fs19 = __toESM(require("fs/promises"), 1);
3499
+ var import_path21 = __toESM(require("path"), 1);
3395
3500
  var import_events4 = require("events");
3396
3501
 
3397
3502
  // src/daemon/file-watcher.ts
3398
3503
  init_cjs_shims();
3399
3504
  var chokidar = __toESM(require("chokidar"), 1);
3400
- var import_path15 = __toESM(require("path"), 1);
3505
+ var import_path16 = __toESM(require("path"), 1);
3401
3506
  var import_events = require("events");
3402
3507
  var CODE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3403
3508
  function isCodeFile3(filePath) {
3404
- const ext = import_path15.default.extname(filePath).toLowerCase();
3509
+ const ext = import_path16.default.extname(filePath).toLowerCase();
3405
3510
  return CODE_EXTENSIONS.includes(ext);
3406
3511
  }
3407
3512
  function createFileWatcher(watchPath) {
3408
3513
  const emitter = new import_events.EventEmitter();
3409
3514
  let watcher = null;
3410
3515
  emitter.start = () => {
3411
- const absolutePath = import_path15.default.resolve(process.cwd(), watchPath);
3516
+ const absolutePath = import_path16.default.resolve(process.cwd(), watchPath);
3412
3517
  watcher = chokidar.watch(absolutePath, {
3413
3518
  ignored: (pathStr) => {
3414
- const relativePath = import_path15.default.relative(process.cwd(), pathStr);
3415
- const segments = relativePath.split(import_path15.default.sep);
3519
+ const relativePath = import_path16.default.relative(process.cwd(), pathStr);
3520
+ const segments = relativePath.split(import_path16.default.sep);
3416
3521
  const ignoreDirs = [
3417
3522
  "node_modules",
3418
3523
  ".git",
@@ -3444,7 +3549,7 @@ function createFileWatcher(watchPath) {
3444
3549
  if (segments.some((segment) => ignoreDirs.includes(segment))) {
3445
3550
  return true;
3446
3551
  }
3447
- const isFile = !!import_path15.default.extname(pathStr);
3552
+ const isFile = !!import_path16.default.extname(pathStr);
3448
3553
  if (isFile && !isCodeFile3(pathStr)) {
3449
3554
  return true;
3450
3555
  }
@@ -3467,17 +3572,17 @@ function createFileWatcher(watchPath) {
3467
3572
  });
3468
3573
  watcher.on("change", (filePath) => {
3469
3574
  if (isCodeFile3(filePath)) {
3470
- emitter.emit("change", import_path15.default.relative(process.cwd(), filePath));
3575
+ emitter.emit("change", import_path16.default.relative(process.cwd(), filePath));
3471
3576
  }
3472
3577
  });
3473
3578
  watcher.on("add", (filePath) => {
3474
3579
  if (isCodeFile3(filePath)) {
3475
- emitter.emit("add", import_path15.default.relative(process.cwd(), filePath));
3580
+ emitter.emit("add", import_path16.default.relative(process.cwd(), filePath));
3476
3581
  }
3477
3582
  });
3478
3583
  watcher.on("unlink", (filePath) => {
3479
3584
  if (isCodeFile3(filePath)) {
3480
- emitter.emit("unlink", import_path15.default.relative(process.cwd(), filePath));
3585
+ emitter.emit("unlink", import_path16.default.relative(process.cwd(), filePath));
3481
3586
  }
3482
3587
  });
3483
3588
  watcher.on("error", (error) => {
@@ -3499,8 +3604,8 @@ function createFileWatcher(watchPath) {
3499
3604
  // src/daemon/heuristic-engine.ts
3500
3605
  init_cjs_shims();
3501
3606
  var import_promises15 = require("fs/promises");
3502
- var import_path16 = require("path");
3503
- var import_path17 = __toESM(require("path"), 1);
3607
+ var import_path17 = require("path");
3608
+ var import_path18 = __toESM(require("path"), 1);
3504
3609
  var import_axios11 = __toESM(require("axios"), 1);
3505
3610
  var GLOBAL_HEURISTICS = [
3506
3611
  {
@@ -3532,7 +3637,7 @@ var HeuristicEngine = class {
3532
3637
  rules = [];
3533
3638
  cachePath;
3534
3639
  constructor() {
3535
- this.cachePath = import_path17.default.join(process.cwd(), ".rigstate", "cache", "heuristics.json");
3640
+ this.cachePath = import_path18.default.join(process.cwd(), ".rigstate", "cache", "heuristics.json");
3536
3641
  this.loadRules();
3537
3642
  }
3538
3643
  async loadRules() {
@@ -3549,7 +3654,7 @@ var HeuristicEngine = class {
3549
3654
  }
3550
3655
  async refreshRules(projectId, apiUrl, apiKey) {
3551
3656
  try {
3552
- await (0, import_promises15.mkdir)((0, import_path16.dirname)(this.cachePath), { recursive: true });
3657
+ await (0, import_promises15.mkdir)((0, import_path17.dirname)(this.cachePath), { recursive: true });
3553
3658
  const endpoint = `${apiUrl}/api/v1/skills/triggers`;
3554
3659
  const response = await import_axios11.default.get(endpoint, {
3555
3660
  headers: {
@@ -3647,9 +3752,9 @@ function createHeuristicEngine() {
3647
3752
 
3648
3753
  // src/daemon/intervention-protocol.ts
3649
3754
  init_cjs_shims();
3650
- var import_chalk16 = __toESM(require("chalk"), 1);
3651
- var fs15 = __toESM(require("fs"), 1);
3652
- var path17 = __toESM(require("path"), 1);
3755
+ var import_chalk17 = __toESM(require("chalk"), 1);
3756
+ var fs16 = __toESM(require("fs"), 1);
3757
+ var path18 = __toESM(require("path"), 1);
3653
3758
  var InterventionProtocol = class {
3654
3759
  activeViolators = /* @__PURE__ */ new Set();
3655
3760
  /**
@@ -3672,18 +3777,18 @@ var InterventionProtocol = class {
3672
3777
  }
3673
3778
  syncLockFile() {
3674
3779
  try {
3675
- const lockDir = path17.join(process.cwd(), ".rigstate");
3676
- if (!fs15.existsSync(lockDir)) fs15.mkdirSync(lockDir, { recursive: true });
3677
- const lockPath = path17.join(lockDir, "guardian.lock");
3780
+ const lockDir = path18.join(process.cwd(), ".rigstate");
3781
+ if (!fs16.existsSync(lockDir)) fs16.mkdirSync(lockDir, { recursive: true });
3782
+ const lockPath = path18.join(lockDir, "guardian.lock");
3678
3783
  if (this.activeViolators.size > 0) {
3679
3784
  const content = `HARD_LOCK_ACTIVE
3680
3785
  Timestamp: ${(/* @__PURE__ */ new Date()).toISOString()}
3681
3786
 
3682
3787
  Blocking Files:
3683
3788
  ${Array.from(this.activeViolators).join("\n")}`;
3684
- fs15.writeFileSync(lockPath, content, "utf-8");
3789
+ fs16.writeFileSync(lockPath, content, "utf-8");
3685
3790
  } else {
3686
- if (fs15.existsSync(lockPath)) fs15.unlinkSync(lockPath);
3791
+ if (fs16.existsSync(lockPath)) fs16.unlinkSync(lockPath);
3687
3792
  }
3688
3793
  } catch (e) {
3689
3794
  console.error("Failed to sync guardian lock file:", e);
@@ -3737,11 +3842,11 @@ ${Array.from(this.activeViolators).join("\n")}`;
3737
3842
  enforce(decision) {
3738
3843
  if (decision.mode === "OPEN") return;
3739
3844
  const icon = decision.mode === "HARD_LOCK" ? "\u{1F6AB}" : "\u26A0\uFE0F";
3740
- const color = decision.mode === "HARD_LOCK" ? import_chalk16.default.bgRed.white.bold : import_chalk16.default.yellow.bold;
3845
+ const color = decision.mode === "HARD_LOCK" ? import_chalk17.default.bgRed.white.bold : import_chalk17.default.yellow.bold;
3741
3846
  console.log("\n" + color(` ${icon} [${decision.mode}] INTERVENTION `));
3742
- console.log(import_chalk16.default.redBright(` ${decision.message}`));
3847
+ console.log(import_chalk17.default.redBright(` ${decision.message}`));
3743
3848
  if (decision.blockCommit) {
3744
- console.log(import_chalk16.default.dim(" \u{1F512} Commit functionality is logically suspended until fixed."));
3849
+ console.log(import_chalk17.default.dim(" \u{1F512} Commit functionality is logically suspended until fixed."));
3745
3850
  }
3746
3851
  }
3747
3852
  };
@@ -3752,9 +3857,9 @@ function createInterventionProtocol() {
3752
3857
  // src/daemon/guardian-monitor.ts
3753
3858
  init_cjs_shims();
3754
3859
  var import_axios12 = __toESM(require("axios"), 1);
3755
- var import_chalk17 = __toESM(require("chalk"), 1);
3860
+ var import_chalk18 = __toESM(require("chalk"), 1);
3756
3861
  var import_promises16 = __toESM(require("fs/promises"), 1);
3757
- var import_path18 = __toESM(require("path"), 1);
3862
+ var import_path19 = __toESM(require("path"), 1);
3758
3863
  var CACHE_FILE3 = ".rigstate/rules-cache.json";
3759
3864
  var CACHE_TTL_MS2 = 5 * 60 * 1e3;
3760
3865
  function createGuardianMonitor(projectId, apiUrl, apiKey) {
@@ -3779,7 +3884,7 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3779
3884
  } catch (error) {
3780
3885
  if (apiUrl.includes("localhost") || apiUrl.includes("127.0.0.1")) {
3781
3886
  const cloudUrl = "https://app.rigstate.com";
3782
- console.log(import_chalk17.default.blue(` \u2601\uFE0F Local API not found. Attempting Cloud Fallback (${cloudUrl})...`));
3887
+ console.log(import_chalk18.default.blue(` \u2601\uFE0F Local API not found. Attempting Cloud Fallback (${cloudUrl})...`));
3783
3888
  try {
3784
3889
  const cloudResponse = await import_axios12.default.get(`${cloudUrl}/api/v1/guardian/rules`, {
3785
3890
  params: { project_id: projectId },
@@ -3788,22 +3893,22 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3788
3893
  });
3789
3894
  if (cloudResponse.data.success && cloudResponse.data.data.rules) {
3790
3895
  rules = cloudResponse.data.data.rules;
3791
- console.log(import_chalk17.default.green(` \u2705 Successfully loaded rules from Rigstate Cloud!`));
3896
+ console.log(import_chalk18.default.green(` \u2705 Successfully loaded rules from Rigstate Cloud!`));
3792
3897
  lastFetch = Date.now();
3793
3898
  await saveCachedRules2(projectId, rules);
3794
3899
  return;
3795
3900
  }
3796
3901
  } catch (cloudError) {
3797
- console.error(import_chalk17.default.red(` \u274C Cloud Fallback failed: ${cloudError.message}`));
3902
+ console.error(import_chalk18.default.red(` \u274C Cloud Fallback failed: ${cloudError.message}`));
3798
3903
  }
3799
3904
  }
3800
- console.error(import_chalk17.default.red(` \u26A0\uFE0F Failed to fetch rules from API: ${error.message}`));
3905
+ console.error(import_chalk18.default.red(` \u26A0\uFE0F Failed to fetch rules from API: ${error.message}`));
3801
3906
  if (error.response) {
3802
- console.error(import_chalk17.default.red(` Status: ${error.response.status} - ${JSON.stringify(error.response.data)}`));
3907
+ console.error(import_chalk18.default.red(` Status: ${error.response.status} - ${JSON.stringify(error.response.data)}`));
3803
3908
  }
3804
3909
  const cached = await loadCachedRules2(projectId);
3805
3910
  if (cached) {
3806
- console.log(import_chalk17.default.yellow(" \u2139\uFE0F Using cached rules as fallback"));
3911
+ console.log(import_chalk18.default.yellow(" \u2139\uFE0F Using cached rules as fallback"));
3807
3912
  rules = cached.rules;
3808
3913
  lastFetch = Date.now();
3809
3914
  return;
@@ -3820,7 +3925,7 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3820
3925
  passed: true
3821
3926
  };
3822
3927
  }
3823
- const absolutePath = import_path18.default.resolve(process.cwd(), filePath);
3928
+ const absolutePath = import_path19.default.resolve(process.cwd(), filePath);
3824
3929
  return checkFile(absolutePath, rules, process.cwd());
3825
3930
  };
3826
3931
  const getRuleCount = () => rules.length;
@@ -3834,7 +3939,7 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3834
3939
  }
3835
3940
  async function loadCachedRules2(projectId) {
3836
3941
  try {
3837
- const cachePath = import_path18.default.join(process.cwd(), CACHE_FILE3);
3942
+ const cachePath = import_path19.default.join(process.cwd(), CACHE_FILE3);
3838
3943
  const content = await import_promises16.default.readFile(cachePath, "utf-8");
3839
3944
  const cached = JSON.parse(content);
3840
3945
  if (cached.projectId !== projectId) {
@@ -3847,7 +3952,7 @@ async function loadCachedRules2(projectId) {
3847
3952
  }
3848
3953
  async function saveCachedRules2(projectId, rules) {
3849
3954
  try {
3850
- const cacheDir = import_path18.default.join(process.cwd(), ".rigstate");
3955
+ const cacheDir = import_path19.default.join(process.cwd(), ".rigstate");
3851
3956
  await import_promises16.default.mkdir(cacheDir, { recursive: true });
3852
3957
  const cached = {
3853
3958
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3856,7 +3961,7 @@ async function saveCachedRules2(projectId, rules) {
3856
3961
  settings: { lmax: 400, lmax_warning: 350 }
3857
3962
  };
3858
3963
  await import_promises16.default.writeFile(
3859
- import_path18.default.join(cacheDir, "rules-cache.json"),
3964
+ import_path19.default.join(cacheDir, "rules-cache.json"),
3860
3965
  JSON.stringify(cached, null, 2)
3861
3966
  );
3862
3967
  } catch {
@@ -3956,37 +4061,37 @@ init_sync_rules();
3956
4061
 
3957
4062
  // src/utils/logger.ts
3958
4063
  init_cjs_shims();
3959
- var import_chalk18 = __toESM(require("chalk"), 1);
4064
+ var import_chalk19 = __toESM(require("chalk"), 1);
3960
4065
  var Logger = class {
3961
4066
  static formatMessage(level, message, context) {
3962
4067
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
3963
4068
  let prefix = "";
3964
4069
  switch (level) {
3965
4070
  case "INFO" /* INFO */:
3966
- prefix = import_chalk18.default.blue(`[${"INFO" /* INFO */}]`);
4071
+ prefix = import_chalk19.default.blue(`[${"INFO" /* INFO */}]`);
3967
4072
  break;
3968
4073
  case "WARN" /* WARN */:
3969
- prefix = import_chalk18.default.yellow(`[${"WARN" /* WARN */}]`);
4074
+ prefix = import_chalk19.default.yellow(`[${"WARN" /* WARN */}]`);
3970
4075
  break;
3971
4076
  case "ERROR" /* ERROR */:
3972
- prefix = import_chalk18.default.red(`[${"ERROR" /* ERROR */}]`);
4077
+ prefix = import_chalk19.default.red(`[${"ERROR" /* ERROR */}]`);
3973
4078
  break;
3974
4079
  case "DEBUG" /* DEBUG */:
3975
- prefix = import_chalk18.default.gray(`[${"DEBUG" /* DEBUG */}]`);
4080
+ prefix = import_chalk19.default.gray(`[${"DEBUG" /* DEBUG */}]`);
3976
4081
  break;
3977
4082
  }
3978
- let output = `${import_chalk18.default.gray(timestamp)} ${prefix} ${message}`;
4083
+ let output = `${import_chalk19.default.gray(timestamp)} ${prefix} ${message}`;
3979
4084
  if (context) {
3980
4085
  if (context instanceof Error) {
3981
4086
  output += `
3982
- ${import_chalk18.default.red(context.stack || context.message)}`;
4087
+ ${import_chalk19.default.red(context.stack || context.message)}`;
3983
4088
  } else if (typeof context === "object") {
3984
4089
  try {
3985
4090
  output += `
3986
- ${import_chalk18.default.gray(JSON.stringify(context, null, 2))}`;
4091
+ ${import_chalk19.default.gray(JSON.stringify(context, null, 2))}`;
3987
4092
  } catch (e) {
3988
4093
  output += `
3989
- ${import_chalk18.default.gray("[Circular or invalid object]")}`;
4094
+ ${import_chalk19.default.gray("[Circular or invalid object]")}`;
3990
4095
  }
3991
4096
  } else {
3992
4097
  output += ` ${String(context)}`;
@@ -4014,7 +4119,7 @@ ${import_chalk18.default.gray("[Circular or invalid object]")}`;
4014
4119
  init_cjs_shims();
4015
4120
  var import_events3 = require("events");
4016
4121
  var import_chokidar = __toESM(require("chokidar"), 1);
4017
- var import_path19 = __toESM(require("path"), 1);
4122
+ var import_path20 = __toESM(require("path"), 1);
4018
4123
  var import_promises17 = __toESM(require("fs/promises"), 1);
4019
4124
  var import_crypto = __toESM(require("crypto"), 1);
4020
4125
  var import_axios15 = __toESM(require("axios"), 1);
@@ -4033,8 +4138,8 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4033
4138
  }
4034
4139
  async start() {
4035
4140
  await this.loadHashes();
4036
- const rulesPath = import_path19.default.join(this.config.watchPath, ".cursor", "rules");
4037
- const watchPattern = import_path19.default.join(rulesPath, "**", "*.mdc");
4141
+ const rulesPath = import_path20.default.join(this.config.watchPath, ".cursor", "rules");
4142
+ const watchPattern = import_path20.default.join(rulesPath, "**", "*.mdc");
4038
4143
  Logger.debug(`\u{1F33E} Harvester watching: ${watchPattern}`);
4039
4144
  this.watcher = import_chokidar.default.watch(watchPattern, {
4040
4145
  persistent: true,
@@ -4055,7 +4160,7 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4055
4160
  }
4056
4161
  }
4057
4162
  async handleFileEvent(filePath, event) {
4058
- const fileName = import_path19.default.basename(filePath);
4163
+ const fileName = import_path20.default.basename(filePath);
4059
4164
  if (this.IGNORED_PREFIXES.some((prefix) => fileName.startsWith(prefix))) {
4060
4165
  return;
4061
4166
  }
@@ -4074,24 +4179,24 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4074
4179
  const content = await import_promises17.default.readFile(filePath, "utf-8");
4075
4180
  const currentHash = this.computeHash(content);
4076
4181
  if (this.ruleHashes.get(filePath) === currentHash) {
4077
- Logger.debug(`Skipping ${import_path19.default.basename(filePath)} (unchanged hash)`);
4182
+ Logger.debug(`Skipping ${import_path20.default.basename(filePath)} (unchanged hash)`);
4078
4183
  return;
4079
4184
  }
4080
4185
  if (content.length < 20) {
4081
- Logger.debug(`Skipping ${import_path19.default.basename(filePath)} (too short)`);
4186
+ Logger.debug(`Skipping ${import_path20.default.basename(filePath)} (too short)`);
4082
4187
  return;
4083
4188
  }
4084
4189
  await this.submitSignal(filePath, content);
4085
4190
  this.ruleHashes.set(filePath, currentHash);
4086
4191
  } catch (error) {
4087
- Logger.warn(`Harvester failed to process ${import_path19.default.basename(filePath)}: ${error.message}`);
4192
+ Logger.warn(`Harvester failed to process ${import_path20.default.basename(filePath)}: ${error.message}`);
4088
4193
  } finally {
4089
4194
  this.processingQueue.delete(filePath);
4090
4195
  }
4091
4196
  }
4092
4197
  async submitSignal(filePath, content) {
4093
- const title = import_path19.default.basename(filePath, ".mdc");
4094
- const relativePath = import_path19.default.relative(process.cwd(), filePath);
4198
+ const title = import_path20.default.basename(filePath, ".mdc");
4199
+ const relativePath = import_path20.default.relative(process.cwd(), filePath);
4095
4200
  Logger.info(`\u{1F33E} Harvesting new knowledge: ${title}`);
4096
4201
  try {
4097
4202
  const descriptionMatch = content.match(/description:\s*(.*)/);
@@ -4125,13 +4230,13 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4125
4230
  }
4126
4231
  }
4127
4232
  async loadHashes() {
4128
- const rulesPath = import_path19.default.join(this.config.watchPath, ".cursor", "rules");
4233
+ const rulesPath = import_path20.default.join(this.config.watchPath, ".cursor", "rules");
4129
4234
  try {
4130
4235
  await import_promises17.default.mkdir(rulesPath, { recursive: true });
4131
4236
  const files = await import_promises17.default.readdir(rulesPath);
4132
4237
  for (const file of files) {
4133
4238
  if (file.endsWith(".mdc")) {
4134
- const fullPath = import_path19.default.join(rulesPath, file);
4239
+ const fullPath = import_path20.default.join(rulesPath, file);
4135
4240
  const content = await import_promises17.default.readFile(fullPath, "utf-8");
4136
4241
  this.ruleHashes.set(fullPath, this.computeHash(content));
4137
4242
  }
@@ -4169,7 +4274,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4169
4274
  }
4170
4275
  async start() {
4171
4276
  if (this.state.isRunning) {
4172
- console.log(import_chalk19.default.yellow("Daemon is already running."));
4277
+ console.log(import_chalk20.default.yellow("Daemon is already running."));
4173
4278
  return;
4174
4279
  }
4175
4280
  this.printWelcome();
@@ -4201,8 +4306,8 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4201
4306
  try {
4202
4307
  await this.setupBridge();
4203
4308
  } catch (e) {
4204
- console.error(import_chalk19.default.yellow(` \u26A0\uFE0F Agent Bridge connection failed: ${e.message}`));
4205
- console.log(import_chalk19.default.dim(" (Daemon will continue with local monitoring only)"));
4309
+ console.error(import_chalk20.default.yellow(` \u26A0\uFE0F Agent Bridge connection failed: ${e.message}`));
4310
+ console.log(import_chalk20.default.dim(" (Daemon will continue with local monitoring only)"));
4206
4311
  }
4207
4312
  }
4208
4313
  this.printActive();
@@ -4218,16 +4323,16 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4218
4323
  }
4219
4324
  }
4220
4325
  printWelcome() {
4221
- console.log(import_chalk19.default.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
4222
- console.log(import_chalk19.default.dim(`Project: ${this.config.projectId}`));
4223
- console.log(import_chalk19.default.dim(`API URL: ${this.config.apiUrl}`));
4224
- console.log(import_chalk19.default.dim(`Watch Path: ${this.config.watchPath}`));
4225
- console.log(import_chalk19.default.dim("\u2500".repeat(50)));
4326
+ console.log(import_chalk20.default.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
4327
+ console.log(import_chalk20.default.dim(`Project: ${this.config.projectId}`));
4328
+ console.log(import_chalk20.default.dim(`API URL: ${this.config.apiUrl}`));
4329
+ console.log(import_chalk20.default.dim(`Watch Path: ${this.config.watchPath}`));
4330
+ console.log(import_chalk20.default.dim("\u2500".repeat(50)));
4226
4331
  }
4227
4332
  printActive() {
4228
- console.log(import_chalk19.default.dim("\u2500".repeat(50)));
4229
- console.log(import_chalk19.default.green.bold("\u2705 Guardian Daemon is now active"));
4230
- console.log(import_chalk19.default.dim("Press Ctrl+C to stop\n"));
4333
+ console.log(import_chalk20.default.dim("\u2500".repeat(50)));
4334
+ console.log(import_chalk20.default.green.bold("\u2705 Guardian Daemon is now active"));
4335
+ console.log(import_chalk20.default.dim("Press Ctrl+C to stop\n"));
4231
4336
  }
4232
4337
  async syncHeuristics() {
4233
4338
  if (!this.heuristicEngine) return;
@@ -4250,7 +4355,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4250
4355
  }
4251
4356
  async getLineCount(filePath) {
4252
4357
  try {
4253
- const content = await fs18.readFile(filePath, "utf-8");
4358
+ const content = await fs19.readFile(filePath, "utf-8");
4254
4359
  return content.split("\n").length;
4255
4360
  } catch (e) {
4256
4361
  return 0;
@@ -4287,7 +4392,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4287
4392
  }
4288
4393
  }
4289
4394
  async updateViolationReport(violations) {
4290
- const reportPath = import_path20.default.join(process.cwd(), ".rigstate", "ACTIVE_VIOLATIONS.md");
4395
+ const reportPath = import_path21.default.join(process.cwd(), ".rigstate", "ACTIVE_VIOLATIONS.md");
4291
4396
  const allViolations = Array.from(this.violationsMap.entries());
4292
4397
  const totalCount = allViolations.reduce((acc, [, v]) => acc + v.length, 0);
4293
4398
  let content = `# \u{1F6E1}\uFE0F Guardian Status: ${totalCount > 0 ? "\u26A0\uFE0F ATTENTION" : "\u2705 PASS"}
@@ -4303,7 +4408,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4303
4408
  } else {
4304
4409
  content += "### \u{1F6A8} Active Violations\n\n";
4305
4410
  for (const [file, fileViolations] of allViolations) {
4306
- const relPath = import_path20.default.relative(process.cwd(), file);
4411
+ const relPath = import_path21.default.relative(process.cwd(), file);
4307
4412
  content += `#### \u{1F4C4} ${relPath}
4308
4413
  `;
4309
4414
  for (const v of fileViolations) {
@@ -4315,7 +4420,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4315
4420
  content += "\n---\n*Rigstate Daemon is watching. Fix violations to clear this report.*";
4316
4421
  }
4317
4422
  try {
4318
- await fs18.writeFile(reportPath, content, "utf-8");
4423
+ await fs19.writeFile(reportPath, content, "utf-8");
4319
4424
  } catch (e) {
4320
4425
  }
4321
4426
  }
@@ -4335,27 +4440,27 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4335
4440
  }
4336
4441
  }
4337
4442
  async setupBridge() {
4338
- console.log(import_chalk19.default.dim("\u{1F309} Connecting to Agent Bridge..."));
4443
+ console.log(import_chalk20.default.dim("\u{1F309} Connecting to Agent Bridge..."));
4339
4444
  this.bridgeListener = createBridgeListener(this.config.projectId, this.config.apiUrl, this.config.apiKey);
4340
4445
  this.bridgeListener.on("task", (task) => {
4341
4446
  this.state.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
4342
4447
  this.state.tasksProcessed++;
4343
- console.log(import_chalk19.default.cyan(`
4448
+ console.log(import_chalk20.default.cyan(`
4344
4449
  \u{1F4E5} New task received: ${task.id}`));
4345
4450
  this.emit("task", task);
4346
4451
  });
4347
4452
  await this.bridgeListener.connect();
4348
- console.log(import_chalk19.default.green(" \u2713 Agent Bridge connected"));
4453
+ console.log(import_chalk20.default.green(" \u2713 Agent Bridge connected"));
4349
4454
  }
4350
4455
  async stop() {
4351
4456
  if (!this.state.isRunning) return;
4352
- console.log(import_chalk19.default.dim("\n\u{1F6D1} Stopping Guardian Daemon..."));
4457
+ console.log(import_chalk20.default.dim("\n\u{1F6D1} Stopping Guardian Daemon..."));
4353
4458
  if (this.fileWatcher) await this.fileWatcher.stop();
4354
4459
  if (this.bridgeListener) await this.bridgeListener.disconnect();
4355
4460
  if (this.harvester) await this.harvester.stop();
4356
4461
  if (this.syncInterval) clearInterval(this.syncInterval);
4357
4462
  this.state.isRunning = false;
4358
- console.log(import_chalk19.default.green("\u2713 Daemon stopped."));
4463
+ console.log(import_chalk20.default.green("\u2713 Daemon stopped."));
4359
4464
  this.emit("stopped", this.state);
4360
4465
  }
4361
4466
  getState() {
@@ -4365,6 +4470,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4365
4470
 
4366
4471
  // src/daemon/factory.ts
4367
4472
  init_config();
4473
+ init_manifest();
4368
4474
  async function createDaemon(options) {
4369
4475
  const apiUrl = getApiUrl();
4370
4476
  let projectId = options.project;
@@ -4394,9 +4500,9 @@ async function createDaemon(options) {
4394
4500
 
4395
4501
  // src/utils/service-manager.ts
4396
4502
  init_cjs_shims();
4397
- var import_chalk20 = __toESM(require("chalk"), 1);
4503
+ var import_chalk21 = __toESM(require("chalk"), 1);
4398
4504
  var import_promises18 = __toESM(require("fs/promises"), 1);
4399
- var import_path21 = __toESM(require("path"), 1);
4505
+ var import_path22 = __toESM(require("path"), 1);
4400
4506
  var import_child_process3 = require("child_process");
4401
4507
  var import_url = require("url");
4402
4508
  async function execShellCommand(cmd) {
@@ -4408,20 +4514,20 @@ async function execShellCommand(cmd) {
4408
4514
  }
4409
4515
  }
4410
4516
  async function enableDaemon() {
4411
- console.log(import_chalk20.default.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
4517
+ console.log(import_chalk21.default.bold("\n\u2699\uFE0F Enabling Rigstate Background Service (macOS)\n"));
4412
4518
  if (process.platform !== "darwin") {
4413
- console.error(import_chalk20.default.red("\u274C Currently only macOS is supported for auto-start."));
4414
- console.error(import_chalk20.default.yellow("PRs welcome for Linux/Windows support!"));
4519
+ console.error(import_chalk21.default.red("\u274C Currently only macOS is supported for auto-start."));
4520
+ console.error(import_chalk21.default.yellow("PRs welcome for Linux/Windows support!"));
4415
4521
  return;
4416
4522
  }
4417
4523
  const homeDir = process.env.HOME || "";
4418
4524
  if (!homeDir) {
4419
- console.error(import_chalk20.default.red("\u274C Could not determine HOME directory."));
4525
+ console.error(import_chalk21.default.red("\u274C Could not determine HOME directory."));
4420
4526
  return;
4421
4527
  }
4422
- const agentsDir = import_path21.default.join(homeDir, "Library/LaunchAgents");
4423
- const logDir = import_path21.default.join(homeDir, ".rigstate/logs");
4424
- const plistPath = import_path21.default.join(agentsDir, "com.rigstate.daemon.plist");
4528
+ const agentsDir = import_path22.default.join(homeDir, "Library/LaunchAgents");
4529
+ const logDir = import_path22.default.join(homeDir, ".rigstate/logs");
4530
+ const plistPath = import_path22.default.join(agentsDir, "com.rigstate.daemon.plist");
4425
4531
  await import_promises18.default.mkdir(agentsDir, { recursive: true });
4426
4532
  await import_promises18.default.mkdir(logDir, { recursive: true });
4427
4533
  const scriptPath = (0, import_url.fileURLToPath)(importMetaUrl);
@@ -4442,9 +4548,9 @@ async function enableDaemon() {
4442
4548
  <key>WorkingDirectory</key>
4443
4549
  <string>${process.cwd()}</string>
4444
4550
  <key>StandardOutPath</key>
4445
- <string>${import_path21.default.join(logDir, "daemon.out.log")}</string>
4551
+ <string>${import_path22.default.join(logDir, "daemon.out.log")}</string>
4446
4552
  <key>StandardErrorPath</key>
4447
- <string>${import_path21.default.join(logDir, "daemon.err.log")}</string>
4553
+ <string>${import_path22.default.join(logDir, "daemon.err.log")}</string>
4448
4554
  <key>RunAtLoad</key>
4449
4555
  <true/>
4450
4556
  <key>KeepAlive</key>
@@ -4458,32 +4564,32 @@ async function enableDaemon() {
4458
4564
  </plist>`;
4459
4565
  try {
4460
4566
  await import_promises18.default.writeFile(plistPath, plistContent);
4461
- console.log(import_chalk20.default.dim(`Created plist at: ${plistPath}`));
4567
+ console.log(import_chalk21.default.dim(`Created plist at: ${plistPath}`));
4462
4568
  try {
4463
4569
  await execShellCommand(`launchctl unload ${plistPath}`);
4464
4570
  } catch (e) {
4465
4571
  }
4466
4572
  await execShellCommand(`launchctl load ${plistPath}`);
4467
- console.log(import_chalk20.default.green("\u2705 Successfully enabled background daemon!"));
4468
- console.log(import_chalk20.default.dim(`Logs: ${logDir}`));
4469
- console.log(import_chalk20.default.dim("The daemon will now restart automatically if it crashes or on reboot."));
4573
+ console.log(import_chalk21.default.green("\u2705 Successfully enabled background daemon!"));
4574
+ console.log(import_chalk21.default.dim(`Logs: ${logDir}`));
4575
+ console.log(import_chalk21.default.dim("The daemon will now restart automatically if it crashes or on reboot."));
4470
4576
  } catch (error) {
4471
- console.error(import_chalk20.default.red("\u274C Failed to enable daemon:"), error.message);
4577
+ console.error(import_chalk21.default.red("\u274C Failed to enable daemon:"), error.message);
4472
4578
  }
4473
4579
  }
4474
4580
  async function disableDaemon() {
4475
- console.log(import_chalk20.default.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
4581
+ console.log(import_chalk21.default.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
4476
4582
  const homeDir = process.env.HOME || "";
4477
- const plistPath = import_path21.default.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
4583
+ const plistPath = import_path22.default.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
4478
4584
  try {
4479
4585
  await execShellCommand(`launchctl unload ${plistPath}`);
4480
4586
  await import_promises18.default.unlink(plistPath);
4481
- console.log(import_chalk20.default.green("\u2705 Successfully disabled background daemon."));
4587
+ console.log(import_chalk21.default.green("\u2705 Successfully disabled background daemon."));
4482
4588
  } catch (error) {
4483
4589
  if (error.code === "ENOENT") {
4484
- console.log(import_chalk20.default.green("\u2705 Daemon was not enabled."));
4590
+ console.log(import_chalk21.default.green("\u2705 Daemon was not enabled."));
4485
4591
  } else {
4486
- console.error(import_chalk20.default.red("\u274C Failed to disable daemon:"), error.message);
4592
+ console.error(import_chalk21.default.red("\u274C Failed to disable daemon:"), error.message);
4487
4593
  }
4488
4594
  }
4489
4595
  }
@@ -4508,14 +4614,14 @@ function createDaemonCommand() {
4508
4614
  }
4509
4615
  const spinner = (0, import_ora8.default)();
4510
4616
  try {
4511
- const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
4617
+ const pidPath = import_path23.default.join(process.cwd(), PID_FILE);
4512
4618
  try {
4513
4619
  const content = await import_promises19.default.readFile(pidPath, "utf-8");
4514
4620
  const pid = parseInt(content.trim(), 10);
4515
4621
  try {
4516
4622
  process.kill(pid, 0);
4517
- console.log(import_chalk21.default.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
4518
- console.log(import_chalk21.default.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
4623
+ console.log(import_chalk22.default.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
4624
+ console.log(import_chalk22.default.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
4519
4625
  `));
4520
4626
  } catch {
4521
4627
  await import_promises19.default.unlink(pidPath).catch(() => {
@@ -4533,7 +4639,7 @@ function createDaemonCommand() {
4533
4639
  spinner.stop();
4534
4640
  await writePidFile();
4535
4641
  process.on("SIGINT", async () => {
4536
- console.log(import_chalk21.default.dim("\n\nShutting down..."));
4642
+ console.log(import_chalk22.default.dim("\n\nShutting down..."));
4537
4643
  await daemonInstance.stop();
4538
4644
  await cleanupPidFile();
4539
4645
  process.exit(0);
@@ -4553,8 +4659,8 @@ function createDaemonCommand() {
4553
4659
  await new Promise(() => {
4554
4660
  });
4555
4661
  } catch (error) {
4556
- spinner.fail(import_chalk21.default.red("Failed to start daemon"));
4557
- console.error(import_chalk21.default.red("Error:"), error.message);
4662
+ spinner.fail(import_chalk22.default.red("Failed to start daemon"));
4663
+ console.error(import_chalk22.default.red("Error:"), error.message);
4558
4664
  process.exit(1);
4559
4665
  }
4560
4666
  });
@@ -4562,7 +4668,7 @@ function createDaemonCommand() {
4562
4668
  }
4563
4669
  async function isRunning() {
4564
4670
  try {
4565
- const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
4671
+ const pidPath = import_path23.default.join(process.cwd(), PID_FILE);
4566
4672
  const content = await import_promises19.default.readFile(pidPath, "utf-8");
4567
4673
  const pid = parseInt(content.trim(), 10);
4568
4674
  try {
@@ -4578,57 +4684,57 @@ async function isRunning() {
4578
4684
  }
4579
4685
  async function writePidFile() {
4580
4686
  try {
4581
- const dir = import_path22.default.join(process.cwd(), ".rigstate");
4687
+ const dir = import_path23.default.join(process.cwd(), ".rigstate");
4582
4688
  await import_promises19.default.mkdir(dir, { recursive: true });
4583
- await import_promises19.default.writeFile(import_path22.default.join(dir, "daemon.pid"), process.pid.toString());
4689
+ await import_promises19.default.writeFile(import_path23.default.join(dir, "daemon.pid"), process.pid.toString());
4584
4690
  } catch {
4585
4691
  }
4586
4692
  }
4587
4693
  async function cleanupPidFile() {
4588
4694
  try {
4589
- await import_promises19.default.unlink(import_path22.default.join(process.cwd(), PID_FILE));
4590
- await import_promises19.default.unlink(import_path22.default.join(process.cwd(), STATE_FILE));
4695
+ await import_promises19.default.unlink(import_path23.default.join(process.cwd(), PID_FILE));
4696
+ await import_promises19.default.unlink(import_path23.default.join(process.cwd(), STATE_FILE));
4591
4697
  } catch {
4592
4698
  }
4593
4699
  }
4594
4700
  async function writeStateFile(state) {
4595
4701
  try {
4596
- const dir = import_path22.default.join(process.cwd(), ".rigstate");
4702
+ const dir = import_path23.default.join(process.cwd(), ".rigstate");
4597
4703
  await import_promises19.default.mkdir(dir, { recursive: true });
4598
4704
  await import_promises19.default.writeFile(
4599
- import_path22.default.join(dir, "daemon.state.json"),
4705
+ import_path23.default.join(dir, "daemon.state.json"),
4600
4706
  JSON.stringify(state, null, 2)
4601
4707
  );
4602
4708
  } catch {
4603
4709
  }
4604
4710
  }
4605
4711
  async function showStatus() {
4606
- console.log(import_chalk21.default.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
4712
+ console.log(import_chalk22.default.bold("\n\u{1F6E1}\uFE0F Guardian Daemon Status\n"));
4607
4713
  const running = await isRunning();
4608
4714
  if (!running) {
4609
- console.log(import_chalk21.default.yellow("Status: Not running"));
4610
- console.log(import_chalk21.default.dim('Use "rigstate daemon" to start.\n'));
4715
+ console.log(import_chalk22.default.yellow("Status: Not running"));
4716
+ console.log(import_chalk22.default.dim('Use "rigstate daemon" to start.\n'));
4611
4717
  return;
4612
4718
  }
4613
- console.log(import_chalk21.default.green("Status: Running"));
4719
+ console.log(import_chalk22.default.green("Status: Running"));
4614
4720
  try {
4615
- const statePath = import_path22.default.join(process.cwd(), STATE_FILE);
4721
+ const statePath = import_path23.default.join(process.cwd(), STATE_FILE);
4616
4722
  const content = await import_promises19.default.readFile(statePath, "utf-8");
4617
4723
  const state = JSON.parse(content);
4618
- console.log(import_chalk21.default.dim("\u2500".repeat(40)));
4724
+ console.log(import_chalk22.default.dim("\u2500".repeat(40)));
4619
4725
  console.log(`Started at: ${state.startedAt || "Unknown"}`);
4620
4726
  console.log(`Files checked: ${state.filesChecked || 0}`);
4621
4727
  console.log(`Violations: ${state.violationsFound || 0}`);
4622
4728
  console.log(`Tasks processed: ${state.tasksProcessed || 0}`);
4623
4729
  console.log(`Last activity: ${state.lastActivity || "None"}`);
4624
- console.log(import_chalk21.default.dim("\u2500".repeat(40)));
4730
+ console.log(import_chalk22.default.dim("\u2500".repeat(40)));
4625
4731
  } catch {
4626
- console.log(import_chalk21.default.dim("(State file not found)"));
4732
+ console.log(import_chalk22.default.dim("(State file not found)"));
4627
4733
  }
4628
4734
  try {
4629
- const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
4735
+ const pidPath = import_path23.default.join(process.cwd(), PID_FILE);
4630
4736
  const pid = await import_promises19.default.readFile(pidPath, "utf-8");
4631
- console.log(import_chalk21.default.dim(`PID: ${pid.trim()}`));
4737
+ console.log(import_chalk22.default.dim(`PID: ${pid.trim()}`));
4632
4738
  } catch {
4633
4739
  }
4634
4740
  console.log("");
@@ -4637,7 +4743,7 @@ async function showStatus() {
4637
4743
  // src/commands/work.ts
4638
4744
  init_cjs_shims();
4639
4745
  var import_commander13 = require("commander");
4640
- var import_chalk23 = __toESM(require("chalk"), 1);
4746
+ var import_chalk24 = __toESM(require("chalk"), 1);
4641
4747
  var import_ora10 = __toESM(require("ora"), 1);
4642
4748
  var import_axios17 = __toESM(require("axios"), 1);
4643
4749
  var import_inquirer3 = __toESM(require("inquirer"), 1);
@@ -4647,11 +4753,11 @@ init_suggest();
4647
4753
  // src/commands/plan.ts
4648
4754
  init_cjs_shims();
4649
4755
  var import_commander12 = require("commander");
4650
- var import_chalk22 = __toESM(require("chalk"), 1);
4756
+ var import_chalk23 = __toESM(require("chalk"), 1);
4651
4757
  var import_ora9 = __toESM(require("ora"), 1);
4652
4758
  var import_axios16 = __toESM(require("axios"), 1);
4653
4759
  var import_promises20 = __toESM(require("fs/promises"), 1);
4654
- var import_path23 = __toESM(require("path"), 1);
4760
+ var import_path24 = __toESM(require("path"), 1);
4655
4761
  var import_inquirer2 = __toESM(require("inquirer"), 1);
4656
4762
  init_config();
4657
4763
  function createPlanCommand() {
@@ -4710,7 +4816,7 @@ async function executePlan(taskId) {
4710
4816
  taskDescription = task.description;
4711
4817
  }
4712
4818
  spinner.start("Generating Context for Frank...");
4713
- const contextPath = import_path23.default.join(process.cwd(), ".rigstate", "CURRENT_CONTEXT.md");
4819
+ const contextPath = import_path24.default.join(process.cwd(), ".rigstate", "CURRENT_CONTEXT.md");
4714
4820
  const contextContent = `
4715
4821
  # \u{1F3AF} Active Mission: ${taskTitle}
4716
4822
  **ID:** ${taskId}
@@ -4725,9 +4831,9 @@ ${taskDescription}
4725
4831
 
4726
4832
  *Generated by Rigstate CLI at ${(/* @__PURE__ */ new Date()).toLocaleString()}*
4727
4833
  `;
4728
- await import_promises20.default.mkdir(import_path23.default.dirname(contextPath), { recursive: true });
4834
+ await import_promises20.default.mkdir(import_path24.default.dirname(contextPath), { recursive: true });
4729
4835
  await import_promises20.default.writeFile(contextPath, contextContent.trim());
4730
- const planPath = import_path23.default.join(process.cwd(), "IMPLEMENTATION_PLAN.md");
4836
+ const planPath = import_path24.default.join(process.cwd(), "IMPLEMENTATION_PLAN.md");
4731
4837
  const planExists = await import_promises20.default.stat(planPath).then(() => true).catch(() => false);
4732
4838
  if (!planExists) {
4733
4839
  const planTemplate = `
@@ -4748,22 +4854,37 @@ ${taskDescription}
4748
4854
  [Frank: Log your progress here]
4749
4855
  `;
4750
4856
  await import_promises20.default.writeFile(planPath, planTemplate.trim());
4751
- spinner.succeed(import_chalk22.default.green("Created new IMPLEMENTATION_PLAN.md"));
4857
+ spinner.succeed(import_chalk23.default.green("Created new IMPLEMENTATION_PLAN.md"));
4752
4858
  } else {
4753
- spinner.info(import_chalk22.default.yellow("IMPLEMENTATION_PLAN.md already exists. Preserving it."));
4859
+ spinner.info(import_chalk23.default.yellow("IMPLEMENTATION_PLAN.md already exists. Preserving it."));
4860
+ }
4861
+ try {
4862
+ spinner.start("\u{1F4E1} Signaling Frank to start drafting...");
4863
+ await import_axios16.default.post(`${apiUrl}/api/v1/agent/bridge`, {
4864
+ project_id: projectId,
4865
+ task_id: realId,
4866
+ status: "APPROVED",
4867
+ proposal: `draft_plan:${taskId}`,
4868
+ summary: `Requesting implementation plan for ${taskTitle}`
4869
+ }, {
4870
+ headers: { "Authorization": `Bearer ${apiKey}` }
4871
+ });
4872
+ spinner.succeed("Signal sent to Agent Bridge.");
4873
+ } catch (e) {
4874
+ spinner.info(import_chalk23.default.dim("Agent Bridge signal skipped (non-critical)."));
4754
4875
  }
4755
4876
  console.log("");
4756
- console.log(import_chalk22.default.bold.blue("\u{1F680} Planning Mode Activated"));
4757
- console.log(import_chalk22.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4758
- console.log(`1. Context loaded into: ${import_chalk22.default.bold(".rigstate/CURRENT_CONTEXT.md")}`);
4759
- console.log(`2. Plan template ready: ${import_chalk22.default.bold("IMPLEMENTATION_PLAN.md")}`);
4877
+ console.log(import_chalk23.default.bold.blue("\u{1F680} Planning Mode Activated"));
4878
+ console.log(import_chalk23.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4879
+ console.log(`1. Context loaded into: ${import_chalk23.default.bold(".rigstate/CURRENT_CONTEXT.md")}`);
4880
+ console.log(`2. Plan template ready: ${import_chalk23.default.bold("IMPLEMENTATION_PLAN.md")}`);
4760
4881
  console.log("");
4761
- console.log(import_chalk22.default.yellow("\u{1F449} NEXT STEP:"));
4762
- console.log(` Open ${import_chalk22.default.bold("IMPLEMENTATION_PLAN.md")} in your IDE.`);
4763
- console.log(` Tell Frank: ${import_chalk22.default.italic('"Read the context and draft the plan."')}`);
4882
+ console.log(import_chalk23.default.green("\u2728 FRANK IS ON IT!"));
4883
+ console.log(import_chalk23.default.dim(" He has received the bridge signal and will begin drafting shortly."));
4884
+ console.log(import_chalk23.default.dim(" No further manual steps required once he wakes up."));
4764
4885
  console.log("");
4765
4886
  } catch (e) {
4766
- spinner.fail(import_chalk22.default.red(`Planning failed: ${e.message}`));
4887
+ spinner.fail(import_chalk23.default.red(`Planning failed: ${e.message}`));
4767
4888
  }
4768
4889
  }
4769
4890
  function getContext() {
@@ -4808,7 +4929,7 @@ async function listInteractive() {
4808
4929
  });
4809
4930
  spinner.stop();
4810
4931
  if (actionableTasks.length === 0) {
4811
- console.log(import_chalk23.default.yellow("Roadmap clear. No actionable tasks found."));
4932
+ console.log(import_chalk24.default.yellow("Roadmap clear. No actionable tasks found."));
4812
4933
  return;
4813
4934
  }
4814
4935
  const choices = actionableTasks.map((t) => {
@@ -4817,7 +4938,7 @@ async function listInteractive() {
4817
4938
  if (t.status === "IN_PROGRESS") icon = "\u{1F525}";
4818
4939
  if (t.status === "ACTIVE") icon = "\u25B6\uFE0F";
4819
4940
  return {
4820
- name: `${icon} ${import_chalk23.default.bold(id)}: ${t.title} [${t.status}]`,
4941
+ name: `${icon} ${import_chalk24.default.bold(id)}: ${t.title} [${t.status}]`,
4821
4942
  value: t.id
4822
4943
  };
4823
4944
  });
@@ -4864,25 +4985,25 @@ async function setTaskStatus(taskId, status) {
4864
4985
  { step_id: realId, status, project_id: projectId },
4865
4986
  { headers: { "Authorization": `Bearer ${apiKey}` } }
4866
4987
  );
4867
- spinner.succeed(import_chalk23.default.green(`Task updated to ${status}.`));
4988
+ spinner.succeed(import_chalk24.default.green(`Task updated to ${status}.`));
4868
4989
  if (status === "IN_PROGRESS") {
4869
- console.log(import_chalk23.default.blue(`
4990
+ console.log(import_chalk24.default.blue(`
4870
4991
  \u{1F4A1} Tip: Provide 'Frank' with context by mentioning @.cursorrules in your chat.`));
4871
4992
  }
4872
4993
  } catch (e) {
4873
- spinner.fail(import_chalk23.default.red(`Failed: ${e.message}`));
4994
+ spinner.fail(import_chalk24.default.red(`Failed: ${e.message}`));
4874
4995
  }
4875
4996
  }
4876
4997
  async function finishTask(taskId) {
4877
4998
  console.log("");
4878
- console.log(import_chalk23.default.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4879
- console.log(import_chalk23.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4999
+ console.log(import_chalk24.default.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
5000
+ console.log(import_chalk24.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
4880
5001
  const auditSpinner = (0, import_ora10.default)(" Analyzing architectural integrity...").start();
4881
5002
  await new Promise((r) => setTimeout(r, 1500));
4882
5003
  auditSpinner.succeed("Architecture: VALIDATED (SEC-ARCH-01 Pass)");
4883
5004
  await setTaskStatus(taskId, "COMPLETED");
4884
5005
  console.log("");
4885
- console.log(import_chalk23.default.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
5006
+ console.log(import_chalk24.default.bold.green("\u{1F389} TASK COMPLETE! Momentum Preserved."));
4886
5007
  const { projectId, apiKey, apiUrl } = getContext2();
4887
5008
  await suggestNextMove(projectId, apiKey, apiUrl);
4888
5009
  }
@@ -4899,40 +5020,36 @@ function getContext2() {
4899
5020
  // src/commands/watch.ts
4900
5021
  init_cjs_shims();
4901
5022
  var import_commander14 = require("commander");
4902
- var import_chalk24 = __toESM(require("chalk"), 1);
5023
+ var import_chalk25 = __toESM(require("chalk"), 1);
4903
5024
  var import_ora11 = __toESM(require("ora"), 1);
4904
5025
  var import_chokidar2 = __toESM(require("chokidar"), 1);
4905
5026
  var import_promises21 = __toESM(require("fs/promises"), 1);
4906
- var import_path24 = __toESM(require("path"), 1);
5027
+ var import_path25 = __toESM(require("path"), 1);
4907
5028
  var import_child_process4 = require("child_process");
4908
5029
  init_config();
4909
5030
  var import_axios18 = __toESM(require("axios"), 1);
4910
5031
  function createWatchCommand() {
4911
5032
  const watch2 = new import_commander14.Command("watch");
4912
5033
  watch2.description("Watch for changes and auto-verify roadmap tasks").option("--no-auto-commit", "Disable auto-commit on verification").option("--no-auto-push", "Disable auto-push after commit").option("--run-tests", "Run tests before committing").option("--test-command <cmd>", "Custom test command (default: npm test)").action(async (options) => {
4913
- console.log(import_chalk24.default.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4914
- console.log(import_chalk24.default.dim("Monitoring for task completion..."));
5034
+ console.log(import_chalk25.default.bold.blue("\u{1F52D} Rigstate Watch Mode"));
5035
+ console.log(import_chalk25.default.dim("Monitoring for task completion..."));
4915
5036
  console.log("");
4916
5037
  let apiKey;
4917
5038
  let projectId;
4918
5039
  try {
4919
5040
  apiKey = getApiKey();
4920
5041
  } catch (e) {
4921
- console.log(import_chalk24.default.red('Not authenticated. Run "rigstate login" first.'));
5042
+ console.log(import_chalk25.default.red('Not authenticated. Run "rigstate login" first.'));
4922
5043
  return;
4923
5044
  }
4924
5045
  projectId = getProjectId();
4925
5046
  if (!projectId) {
4926
- try {
4927
- const manifestPath = import_path24.default.join(process.cwd(), ".rigstate");
4928
- const content = await import_promises21.default.readFile(manifestPath, "utf-8");
4929
- const manifest = JSON.parse(content);
4930
- projectId = manifest.project_id;
4931
- } catch (e) {
4932
- }
5047
+ const { loadManifest: loadManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
5048
+ const manifest = await loadManifest2();
5049
+ if (manifest?.project_id) projectId = manifest.project_id;
4933
5050
  }
4934
5051
  if (!projectId) {
4935
- console.log(import_chalk24.default.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
5052
+ console.log(import_chalk25.default.red('No project context. Run "rigstate link" or "rigstate sync --project <id>" first.'));
4936
5053
  return;
4937
5054
  }
4938
5055
  const apiUrl = getApiUrl();
@@ -4942,8 +5059,8 @@ function createWatchCommand() {
4942
5059
  runTests: options.runTests || false,
4943
5060
  testCommand: options.testCommand || "npm test"
4944
5061
  };
4945
- console.log(import_chalk24.default.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4946
- console.log(import_chalk24.default.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
5062
+ console.log(import_chalk25.default.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
5063
+ console.log(import_chalk25.default.dim(`Auto-push: ${config2.autoPush ? "ON" : "OFF"}`));
4947
5064
  console.log("");
4948
5065
  const fetchActiveTask = async () => {
4949
5066
  try {
@@ -4971,7 +5088,7 @@ function createWatchCommand() {
4971
5088
  };
4972
5089
  const checkCriteria = async (criteria) => {
4973
5090
  try {
4974
- const fullPath = import_path24.default.resolve(process.cwd(), criteria.path);
5091
+ const fullPath = import_path25.default.resolve(process.cwd(), criteria.path);
4975
5092
  switch (criteria.type) {
4976
5093
  case "file_exists":
4977
5094
  await import_promises21.default.access(fullPath);
@@ -5010,7 +5127,7 @@ function createWatchCommand() {
5010
5127
  }, {
5011
5128
  headers: { Authorization: `Bearer ${apiKey}` }
5012
5129
  });
5013
- spinner.succeed(import_chalk24.default.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
5130
+ spinner.succeed(import_chalk25.default.green(`\u2705 Task #${task.step_number} completed: ${task.title}`));
5014
5131
  if (config2.autoCommit) {
5015
5132
  spinner.start("Committing changes...");
5016
5133
  try {
@@ -5032,7 +5149,7 @@ function createWatchCommand() {
5032
5149
  }
5033
5150
  }
5034
5151
  console.log("");
5035
- console.log(import_chalk24.default.blue("Watching for next task..."));
5152
+ console.log(import_chalk25.default.blue("Watching for next task..."));
5036
5153
  } catch (e) {
5037
5154
  spinner.fail(`Failed to complete task: ${e.message}`);
5038
5155
  }
@@ -5045,7 +5162,7 @@ function createWatchCommand() {
5045
5162
  const task = await fetchActiveTask();
5046
5163
  if (!task) {
5047
5164
  if (currentTask) {
5048
- console.log(import_chalk24.default.green("\u{1F389} All tasks completed! Watching for new tasks..."));
5165
+ console.log(import_chalk25.default.green("\u{1F389} All tasks completed! Watching for new tasks..."));
5049
5166
  currentTask = null;
5050
5167
  }
5051
5168
  isProcessing = false;
@@ -5054,10 +5171,10 @@ function createWatchCommand() {
5054
5171
  if (!currentTask || currentTask.id !== task.id) {
5055
5172
  currentTask = task;
5056
5173
  console.log("");
5057
- console.log(import_chalk24.default.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
5058
- console.log(import_chalk24.default.dim(`Status: ${task.status}`));
5174
+ console.log(import_chalk25.default.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
5175
+ console.log(import_chalk25.default.dim(`Status: ${task.status}`));
5059
5176
  if (task.verification_criteria) {
5060
- console.log(import_chalk24.default.dim("Verification: Auto-checking criteria..."));
5177
+ console.log(import_chalk25.default.dim("Verification: Auto-checking criteria..."));
5061
5178
  }
5062
5179
  }
5063
5180
  if (task.verification_criteria && Array.isArray(task.verification_criteria)) {
@@ -5070,7 +5187,7 @@ function createWatchCommand() {
5070
5187
  }
5071
5188
  }
5072
5189
  if (allPassed) {
5073
- console.log(import_chalk24.default.green("\u2713 All verification criteria passed!"));
5190
+ console.log(import_chalk25.default.green("\u2713 All verification criteria passed!"));
5074
5191
  await completeTask(task.id, task);
5075
5192
  currentTask = null;
5076
5193
  }
@@ -5095,11 +5212,11 @@ function createWatchCommand() {
5095
5212
  setTimeout(() => processActiveTask(), 500);
5096
5213
  }
5097
5214
  });
5098
- console.log(import_chalk24.default.dim("Watching for file changes... (Ctrl+C to exit)"));
5215
+ console.log(import_chalk25.default.dim("Watching for file changes... (Ctrl+C to exit)"));
5099
5216
  setInterval(() => processActiveTask(), 3e4);
5100
5217
  process.on("SIGINT", () => {
5101
5218
  console.log("");
5102
- console.log(import_chalk24.default.dim("Watch mode stopped."));
5219
+ console.log(import_chalk25.default.dim("Watch mode stopped."));
5103
5220
  watcher.close();
5104
5221
  process.exit(0);
5105
5222
  });
@@ -5110,13 +5227,11 @@ function createWatchCommand() {
5110
5227
  // src/commands/focus.ts
5111
5228
  init_cjs_shims();
5112
5229
  var import_commander15 = require("commander");
5113
- var import_chalk25 = __toESM(require("chalk"), 1);
5230
+ var import_chalk26 = __toESM(require("chalk"), 1);
5114
5231
  var import_ora12 = __toESM(require("ora"), 1);
5115
5232
  init_config();
5116
5233
  var import_axios19 = __toESM(require("axios"), 1);
5117
5234
  var import_child_process5 = require("child_process");
5118
- var import_promises22 = __toESM(require("fs/promises"), 1);
5119
- var import_path25 = __toESM(require("path"), 1);
5120
5235
  function createFocusCommand() {
5121
5236
  const focus = new import_commander15.Command("focus");
5122
5237
  focus.alias("task").description("Get the next active roadmap task and copy its prompt to clipboard").option("--no-copy", "Do not copy to clipboard").action(async (options) => {
@@ -5126,21 +5241,17 @@ function createFocusCommand() {
5126
5241
  try {
5127
5242
  apiKey = getApiKey();
5128
5243
  } catch (e) {
5129
- spinner.fail(import_chalk25.default.red('Not authenticated. Run "rigstate login" first.'));
5244
+ spinner.fail(import_chalk26.default.red('Not authenticated. Run "rigstate login" first.'));
5130
5245
  return;
5131
5246
  }
5132
5247
  projectId = getProjectId();
5133
5248
  if (!projectId) {
5134
- try {
5135
- const manifestPath = import_path25.default.join(process.cwd(), ".rigstate");
5136
- const content = await import_promises22.default.readFile(manifestPath, "utf-8");
5137
- const manifest = JSON.parse(content);
5138
- projectId = manifest.project_id;
5139
- } catch (e) {
5140
- }
5249
+ const { loadManifest: loadManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
5250
+ const manifest = await loadManifest2();
5251
+ if (manifest?.project_id) projectId = manifest.project_id;
5141
5252
  }
5142
5253
  if (!projectId) {
5143
- spinner.fail(import_chalk25.default.red('No project context. Run "rigstate link" first.'));
5254
+ spinner.fail(import_chalk26.default.red('No project context. Run "rigstate link" first.'));
5144
5255
  return;
5145
5256
  }
5146
5257
  const apiUrl = getApiUrl();
@@ -5171,41 +5282,41 @@ function createFocusCommand() {
5171
5282
  const nextTask = activeTasks[0];
5172
5283
  spinner.stop();
5173
5284
  console.log("");
5174
- console.log(import_chalk25.default.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
5175
- const statusColor = nextTask.status === "IN_PROGRESS" ? import_chalk25.default.yellow : nextTask.status === "ACTIVE" ? import_chalk25.default.green : import_chalk25.default.dim;
5176
- console.log(import_chalk25.default.dim("Status: ") + statusColor(nextTask.status));
5177
- console.log(import_chalk25.default.dim("\u2500".repeat(60)));
5285
+ console.log(import_chalk26.default.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
5286
+ const statusColor = nextTask.status === "IN_PROGRESS" ? import_chalk26.default.yellow : nextTask.status === "ACTIVE" ? import_chalk26.default.green : import_chalk26.default.dim;
5287
+ console.log(import_chalk26.default.dim("Status: ") + statusColor(nextTask.status));
5288
+ console.log(import_chalk26.default.dim("\u2500".repeat(60)));
5178
5289
  if (nextTask.prompt_content) {
5179
- console.log(import_chalk25.default.white(nextTask.prompt_content));
5180
- console.log(import_chalk25.default.dim("\u2500".repeat(60)));
5290
+ console.log(import_chalk26.default.white(nextTask.prompt_content));
5291
+ console.log(import_chalk26.default.dim("\u2500".repeat(60)));
5181
5292
  if (options.copy !== false) {
5182
5293
  try {
5183
5294
  if (process.platform === "darwin") {
5184
5295
  (0, import_child_process5.execSync)("pbcopy", { input: nextTask.prompt_content });
5185
- console.log(import_chalk25.default.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
5296
+ console.log(import_chalk26.default.green("\u2705 Prompt copied to clipboard! Ready to paste (Cmd+V)."));
5186
5297
  } else if (process.platform === "linux") {
5187
5298
  try {
5188
5299
  (0, import_child_process5.execSync)("xclip -selection clipboard", { input: nextTask.prompt_content });
5189
- console.log(import_chalk25.default.green("\u2705 Prompt copied to clipboard!"));
5300
+ console.log(import_chalk26.default.green("\u2705 Prompt copied to clipboard!"));
5190
5301
  } catch (e) {
5191
- console.log(import_chalk25.default.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
5302
+ console.log(import_chalk26.default.yellow("\u2139\uFE0F Copy prompt manually (xclip not available)"));
5192
5303
  }
5193
5304
  } else {
5194
- console.log(import_chalk25.default.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
5305
+ console.log(import_chalk26.default.yellow("\u2139\uFE0F Copy prompt manually (Auto-copy not supported on this OS)"));
5195
5306
  }
5196
5307
  } catch (e) {
5197
5308
  }
5198
5309
  }
5199
5310
  } else {
5200
- console.log(import_chalk25.default.yellow("No prompt instructions available."));
5311
+ console.log(import_chalk26.default.yellow("No prompt instructions available."));
5201
5312
  if (nextTask.architectural_brief) {
5202
- console.log(import_chalk25.default.bold("Brief:"));
5313
+ console.log(import_chalk26.default.bold("Brief:"));
5203
5314
  console.log(nextTask.architectural_brief);
5204
5315
  }
5205
5316
  }
5206
5317
  console.log("");
5207
5318
  } catch (e) {
5208
- spinner.fail(import_chalk25.default.red(`Failed to fetch task: ${e.message}`));
5319
+ spinner.fail(import_chalk26.default.red(`Failed to fetch task: ${e.message}`));
5209
5320
  }
5210
5321
  });
5211
5322
  return focus;
@@ -5217,26 +5328,26 @@ init_env();
5217
5328
  // src/commands/config.ts
5218
5329
  init_cjs_shims();
5219
5330
  var import_commander16 = require("commander");
5220
- var import_chalk26 = __toESM(require("chalk"), 1);
5331
+ var import_chalk27 = __toESM(require("chalk"), 1);
5221
5332
  init_config();
5222
5333
  function createConfigCommand() {
5223
5334
  const config2 = new import_commander16.Command("config");
5224
5335
  config2.description("View or modify Rigstate configuration").argument("[key]", "Configuration key to view/set (api_key, project_id, api_url)").argument("[value]", "Value to set").action(async (key, value) => {
5225
5336
  if (!key) {
5226
- console.log(import_chalk26.default.bold("Rigstate Configuration"));
5227
- console.log(import_chalk26.default.dim("\u2500".repeat(40)));
5337
+ console.log(import_chalk27.default.bold("Rigstate Configuration"));
5338
+ console.log(import_chalk27.default.dim("\u2500".repeat(40)));
5228
5339
  try {
5229
5340
  const apiKey = getApiKey();
5230
- console.log(`${import_chalk26.default.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
5341
+ console.log(`${import_chalk27.default.cyan("api_key")}: ${apiKey.substring(0, 20)}...`);
5231
5342
  } catch (e) {
5232
- console.log(`${import_chalk26.default.cyan("api_key")}: ${import_chalk26.default.dim("(not set)")}`);
5343
+ console.log(`${import_chalk27.default.cyan("api_key")}: ${import_chalk27.default.dim("(not set)")}`);
5233
5344
  }
5234
5345
  const projectId = getProjectId();
5235
- console.log(`${import_chalk26.default.cyan("project_id")}: ${projectId || import_chalk26.default.dim("(not set)")}`);
5346
+ console.log(`${import_chalk27.default.cyan("project_id")}: ${projectId || import_chalk27.default.dim("(not set)")}`);
5236
5347
  const apiUrl = getApiUrl();
5237
- console.log(`${import_chalk26.default.cyan("api_url")}: ${apiUrl}`);
5348
+ console.log(`${import_chalk27.default.cyan("api_url")}: ${apiUrl}`);
5238
5349
  console.log("");
5239
- console.log(import_chalk26.default.dim('Use "rigstate config <key> <value>" to set a value.'));
5350
+ console.log(import_chalk27.default.dim('Use "rigstate config <key> <value>" to set a value.'));
5240
5351
  return;
5241
5352
  }
5242
5353
  if (!value) {
@@ -5246,37 +5357,37 @@ function createConfigCommand() {
5246
5357
  const apiKey = getApiKey();
5247
5358
  console.log(apiKey);
5248
5359
  } catch (e) {
5249
- console.log(import_chalk26.default.dim("(not set)"));
5360
+ console.log(import_chalk27.default.dim("(not set)"));
5250
5361
  }
5251
5362
  break;
5252
5363
  case "project_id":
5253
- console.log(getProjectId() || import_chalk26.default.dim("(not set)"));
5364
+ console.log(getProjectId() || import_chalk27.default.dim("(not set)"));
5254
5365
  break;
5255
5366
  case "api_url":
5256
5367
  console.log(getApiUrl());
5257
5368
  break;
5258
5369
  default:
5259
- console.log(import_chalk26.default.red(`Unknown config key: ${key}`));
5260
- console.log(import_chalk26.default.dim("Valid keys: api_key, project_id, api_url"));
5370
+ console.log(import_chalk27.default.red(`Unknown config key: ${key}`));
5371
+ console.log(import_chalk27.default.dim("Valid keys: api_key, project_id, api_url"));
5261
5372
  }
5262
5373
  return;
5263
5374
  }
5264
5375
  switch (key) {
5265
5376
  case "api_key":
5266
5377
  setApiKey(value);
5267
- console.log(import_chalk26.default.green(`\u2705 api_key updated`));
5378
+ console.log(import_chalk27.default.green(`\u2705 api_key updated`));
5268
5379
  break;
5269
5380
  case "project_id":
5270
5381
  setProjectId(value);
5271
- console.log(import_chalk26.default.green(`\u2705 project_id updated`));
5382
+ console.log(import_chalk27.default.green(`\u2705 project_id updated`));
5272
5383
  break;
5273
5384
  case "api_url":
5274
5385
  setApiUrl(value);
5275
- console.log(import_chalk26.default.green(`\u2705 api_url updated`));
5386
+ console.log(import_chalk27.default.green(`\u2705 api_url updated`));
5276
5387
  break;
5277
5388
  default:
5278
- console.log(import_chalk26.default.red(`Unknown config key: ${key}`));
5279
- console.log(import_chalk26.default.dim("Valid keys: api_key, project_id, api_url"));
5389
+ console.log(import_chalk27.default.red(`Unknown config key: ${key}`));
5390
+ console.log(import_chalk27.default.dim("Valid keys: api_key, project_id, api_url"));
5280
5391
  }
5281
5392
  });
5282
5393
  return config2;
@@ -5285,10 +5396,10 @@ function createConfigCommand() {
5285
5396
  // src/commands/mcp.ts
5286
5397
  init_cjs_shims();
5287
5398
  var import_commander17 = require("commander");
5288
- var import_chalk27 = __toESM(require("chalk"), 1);
5399
+ var import_chalk28 = __toESM(require("chalk"), 1);
5289
5400
  var import_child_process6 = require("child_process");
5290
5401
  var import_path26 = __toESM(require("path"), 1);
5291
- var import_fs = __toESM(require("fs"), 1);
5402
+ var import_fs3 = __toESM(require("fs"), 1);
5292
5403
  var import_url2 = require("url");
5293
5404
  init_config();
5294
5405
  var __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
@@ -5306,21 +5417,21 @@ function createMcpCommand() {
5306
5417
  ];
5307
5418
  let serverPath = "";
5308
5419
  for (const p of possiblePaths) {
5309
- if (import_fs.default.existsSync(p)) {
5420
+ if (import_fs3.default.existsSync(p)) {
5310
5421
  serverPath = p;
5311
5422
  break;
5312
5423
  }
5313
5424
  }
5314
5425
  if (!serverPath) {
5315
- console.error(import_chalk27.default.red("\u274C Error: Rigstate MCP Server binary not found."));
5316
- console.error(import_chalk27.default.yellow("Please ensure that the mcp package is built:"));
5317
- console.error(import_chalk27.default.white(" cd packages/mcp && npm run build"));
5426
+ console.error(import_chalk28.default.red("\u274C Error: Rigstate MCP Server binary not found."));
5427
+ console.error(import_chalk28.default.yellow("Please ensure that the mcp package is built:"));
5428
+ console.error(import_chalk28.default.white(" cd packages/mcp && npm run build"));
5318
5429
  console.error("");
5319
- console.error(import_chalk27.default.dim("Or run directly with:"));
5320
- console.error(import_chalk27.default.white(" npx @rigstate/mcp"));
5430
+ console.error(import_chalk28.default.dim("Or run directly with:"));
5431
+ console.error(import_chalk28.default.white(" npx @rigstate/mcp"));
5321
5432
  process.exit(1);
5322
5433
  }
5323
- console.log(import_chalk27.default.dim(`Starting MCP server from: ${serverPath}`));
5434
+ console.log(import_chalk28.default.dim(`Starting MCP server from: ${serverPath}`));
5324
5435
  const env = { ...process.env };
5325
5436
  try {
5326
5437
  const apiKey = getApiKey();
@@ -5339,7 +5450,7 @@ function createMcpCommand() {
5339
5450
  stdio: ["inherit", "inherit", "inherit"]
5340
5451
  });
5341
5452
  worker.on("error", (err) => {
5342
- console.error(import_chalk27.default.red(`\u274C Failed to start MCP server: ${err.message}`));
5453
+ console.error(import_chalk28.default.red(`\u274C Failed to start MCP server: ${err.message}`));
5343
5454
  process.exit(1);
5344
5455
  });
5345
5456
  worker.on("exit", (code) => {
@@ -5354,7 +5465,7 @@ function createMcpCommand() {
5354
5465
  // src/commands/nexus.ts
5355
5466
  init_cjs_shims();
5356
5467
  var import_commander18 = require("commander");
5357
- var import_chalk29 = __toESM(require("chalk"), 1);
5468
+ var import_chalk30 = __toESM(require("chalk"), 1);
5358
5469
 
5359
5470
  // src/nexus/dispatcher.ts
5360
5471
  init_cjs_shims();
@@ -5422,7 +5533,7 @@ var HiveScrubber = class {
5422
5533
  };
5423
5534
 
5424
5535
  // src/hive/gateway.ts
5425
- var import_chalk28 = __toESM(require("chalk"), 1);
5536
+ var import_chalk29 = __toESM(require("chalk"), 1);
5426
5537
  var HiveGateway = class {
5427
5538
  client;
5428
5539
  enabled;
@@ -5432,7 +5543,7 @@ var HiveGateway = class {
5432
5543
  constructor(baseUrl, token) {
5433
5544
  this.enabled = !!token;
5434
5545
  if (!this.enabled) {
5435
- console.log(import_chalk28.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
5546
+ console.log(import_chalk29.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
5436
5547
  }
5437
5548
  this.client = import_axios20.default.create({
5438
5549
  baseURL: baseUrl,
@@ -5452,23 +5563,23 @@ var HiveGateway = class {
5452
5563
  if (!this.enabled) return false;
5453
5564
  const now = Date.now();
5454
5565
  if (now - this.lastSignalTime < this.MIN_INTERVAL_MS) {
5455
- console.warn(import_chalk28.default.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
5566
+ console.warn(import_chalk29.default.yellow("\u23F3 Hive Gateway Throttled. Signal dropped to preventing spam."));
5456
5567
  return false;
5457
5568
  }
5458
5569
  const scrubResult = HiveScrubber.scrub(signal.ruleContent);
5459
5570
  if (scrubResult.riskScore > 20) {
5460
- console.error(import_chalk28.default.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
5571
+ console.error(import_chalk29.default.red(`\u{1F6D1} HIVE BLOCKED: Signal contains sensitive data (Risk: ${scrubResult.riskScore})`));
5461
5572
  return false;
5462
5573
  }
5463
5574
  try {
5464
- console.log(import_chalk28.default.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
5575
+ console.log(import_chalk29.default.blue(`\u{1F4E1} Uplinking to Hive... [${signal.vector}]`));
5465
5576
  const payload = { ...signal, ruleContent: scrubResult.sanitizedContent };
5466
5577
  await this.client.post("/signal", payload);
5467
5578
  this.lastSignalTime = now;
5468
- console.log(import_chalk28.default.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
5579
+ console.log(import_chalk29.default.green("\u2705 Signal Received by Hive Core. Knowledge Shared."));
5469
5580
  return true;
5470
5581
  } catch (error) {
5471
- console.error(import_chalk28.default.red(`\u274C Hive Transmission Failed: ${error.message}`));
5582
+ console.error(import_chalk29.default.red(`\u274C Hive Transmission Failed: ${error.message}`));
5472
5583
  return false;
5473
5584
  }
5474
5585
  }
@@ -5570,10 +5681,10 @@ var import_inquirer4 = __toESM(require("inquirer"), 1);
5570
5681
  function createNexusCommand() {
5571
5682
  const command = new import_commander18.Command("nexus");
5572
5683
  command.description("Interact with The Multi-Agent Nexus (Phase 8)").argument("<intent>", "The natural language instruction for the swarm").option("--dry-run", "Enable Dry-Run mode (Kill-Switch Active)", true).option("--force", "Disable Dry-Run mode (DANGEROUS)", false).action(async (intent, options) => {
5573
- console.log(import_chalk29.default.bold.magenta("\n\u{1F981} Welcome to The Nexus (Phase 8)\n"));
5684
+ console.log(import_chalk30.default.bold.magenta("\n\u{1F981} Welcome to The Nexus (Phase 8)\n"));
5574
5685
  const dryRun = !options.force;
5575
5686
  if (!dryRun) {
5576
- console.log(import_chalk29.default.black.bgYellow(" WARNING ") + import_chalk29.default.yellow(" Dry-Run disabled! Eitri is authorized to write code."));
5687
+ console.log(import_chalk30.default.black.bgYellow(" WARNING ") + import_chalk30.default.yellow(" Dry-Run disabled! Eitri is authorized to write code."));
5577
5688
  const { confirm } = await import_inquirer4.default.prompt([{
5578
5689
  type: "confirm",
5579
5690
  name: "confirm",
@@ -5594,26 +5705,26 @@ function createNexusCommand() {
5594
5705
  };
5595
5706
  const dispatcher = new NexusDispatcher(context);
5596
5707
  dispatcher.on("order:created", (o) => {
5597
- console.log(import_chalk29.default.blue(`\u{1F195} [${o.id.slice(0, 6)}] Order Created: `) + o.intent);
5708
+ console.log(import_chalk30.default.blue(`\u{1F195} [${o.id.slice(0, 6)}] Order Created: `) + o.intent);
5598
5709
  });
5599
5710
  dispatcher.on("order:started", (o) => {
5600
- console.log(import_chalk29.default.yellow(`\u23F3 [${o.id.slice(0, 6)}] Processing...`));
5711
+ console.log(import_chalk30.default.yellow(`\u23F3 [${o.id.slice(0, 6)}] Processing...`));
5601
5712
  });
5602
5713
  dispatcher.on("order:blocked", (o) => {
5603
- console.log(import_chalk29.default.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
5604
- console.log(import_chalk29.default.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
5605
- console.log(import_chalk29.default.dim(" Run with --force to execute automatically (NOT RECOMMENDED)."));
5714
+ console.log(import_chalk30.default.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
5715
+ console.log(import_chalk30.default.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
5716
+ console.log(import_chalk30.default.dim(" Run with --force to execute automatically (NOT RECOMMENDED)."));
5606
5717
  });
5607
- dispatcher.on("agent:SINDRE", (o) => console.log(import_chalk29.default.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
5608
- dispatcher.on("agent:EITRI", (o) => console.log(import_chalk29.default.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
5609
- console.log(import_chalk29.default.dim("\u{1F9E0} Frank is analyzing your intent..."));
5718
+ dispatcher.on("agent:SINDRE", (o) => console.log(import_chalk30.default.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
5719
+ dispatcher.on("agent:EITRI", (o) => console.log(import_chalk30.default.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
5720
+ console.log(import_chalk30.default.dim("\u{1F9E0} Frank is analyzing your intent..."));
5610
5721
  await new Promise((r) => setTimeout(r, 800));
5611
5722
  if (intent.toLowerCase().includes("db") || intent.toLowerCase().includes("database")) {
5612
5723
  await dispatcher.dispatch("FRANK", "SINDRE", intent, "db.analyze", { raw: intent });
5613
5724
  } else if (intent.toLowerCase().includes("create") || intent.toLowerCase().includes("code")) {
5614
5725
  await dispatcher.dispatch("FRANK", "EITRI", intent, "fs.write", { path: "src/demo.ts", content: "// demo" });
5615
5726
  } else {
5616
- console.log(import_chalk29.default.gray("Frank didn't understand. Try 'create file' or 'check database'."));
5727
+ console.log(import_chalk30.default.gray("Frank didn't understand. Try 'create file' or 'check database'."));
5617
5728
  }
5618
5729
  });
5619
5730
  return command;
@@ -5625,7 +5736,7 @@ init_sync_rules();
5625
5736
  // src/commands/override.ts
5626
5737
  init_cjs_shims();
5627
5738
  var import_commander19 = require("commander");
5628
- var import_chalk30 = __toESM(require("chalk"), 1);
5739
+ var import_chalk31 = __toESM(require("chalk"), 1);
5629
5740
  init_governance();
5630
5741
  init_config();
5631
5742
  var import_axios21 = __toESM(require("axios"), 1);
@@ -5633,19 +5744,19 @@ function createOverrideCommand() {
5633
5744
  const override = new import_commander19.Command("override");
5634
5745
  override.description("Emergency Override for Governance Soft Locks").argument("<violationId>", 'ID of the violation to override (or "all")').requiredOption("-r, --reason <reason>", "Description of why this override is necessary").action(async (violationId, options) => {
5635
5746
  const { reason } = options;
5636
- console.log(import_chalk30.default.bold(`
5747
+ console.log(import_chalk31.default.bold(`
5637
5748
  \u{1F513} Initiating Governance Override Protocol...`));
5638
5749
  const session = await getSessionState(process.cwd());
5639
5750
  if (session.status !== "SOFT_LOCK") {
5640
- console.log(import_chalk30.default.yellow(" Info: Session is not currently locked."));
5751
+ console.log(import_chalk31.default.yellow(" Info: Session is not currently locked."));
5641
5752
  return;
5642
5753
  }
5643
- console.log(import_chalk30.default.dim(` Active Violation: ${session.active_violation}`));
5644
- console.log(import_chalk30.default.dim(` Reason Provided: "${reason}"`));
5754
+ console.log(import_chalk31.default.dim(` Active Violation: ${session.active_violation}`));
5755
+ console.log(import_chalk31.default.dim(` Reason Provided: "${reason}"`));
5645
5756
  const success = await performOverride(violationId, reason, process.cwd());
5646
5757
  if (success) {
5647
- console.log(import_chalk30.default.green(` \u2705 Session UNLOCKED.`));
5648
- console.log(import_chalk30.default.dim(` This event has been logged to the Mission Report.`));
5758
+ console.log(import_chalk31.default.green(` \u2705 Session UNLOCKED.`));
5759
+ console.log(import_chalk31.default.dim(` This event has been logged to the Mission Report.`));
5649
5760
  try {
5650
5761
  const projectId = getProjectId();
5651
5762
  if (projectId) {
@@ -5662,13 +5773,13 @@ function createOverrideCommand() {
5662
5773
  }, {
5663
5774
  headers: { Authorization: `Bearer ${apiKey}` }
5664
5775
  });
5665
- console.log(import_chalk30.default.dim(` \u2601 Audit log synced to Cloud.`));
5776
+ console.log(import_chalk31.default.dim(` \u2601 Audit log synced to Cloud.`));
5666
5777
  }
5667
5778
  } catch (e) {
5668
- console.log(import_chalk30.default.dim(` (Cloud audit sync failed: ${e.message})`));
5779
+ console.log(import_chalk31.default.dim(` (Cloud audit sync failed: ${e.message})`));
5669
5780
  }
5670
5781
  } else {
5671
- console.log(import_chalk30.default.red(` \u{1F6D1} Override Failed. Check project configuration.`));
5782
+ console.log(import_chalk31.default.red(` \u{1F6D1} Override Failed. Check project configuration.`));
5672
5783
  }
5673
5784
  });
5674
5785
  return override;
@@ -5677,7 +5788,7 @@ function createOverrideCommand() {
5677
5788
  // src/commands/idea.ts
5678
5789
  init_cjs_shims();
5679
5790
  var import_commander20 = require("commander");
5680
- var import_chalk31 = __toESM(require("chalk"), 1);
5791
+ var import_chalk32 = __toESM(require("chalk"), 1);
5681
5792
  var import_ora13 = __toESM(require("ora"), 1);
5682
5793
  var import_axios22 = __toESM(require("axios"), 1);
5683
5794
  var import_inquirer5 = __toESM(require("inquirer"), 1);
@@ -5689,7 +5800,7 @@ function createIdeaCommand() {
5689
5800
  const apiUrl = getApiUrl();
5690
5801
  const projectId = getProjectId();
5691
5802
  if (!projectId) {
5692
- console.error(import_chalk31.default.red("Project context missing. Run rigstate link."));
5803
+ console.error(import_chalk32.default.red("Project context missing. Run rigstate link."));
5693
5804
  process.exit(1);
5694
5805
  }
5695
5806
  let ideaTitle = title;
@@ -5725,14 +5836,14 @@ function createIdeaCommand() {
5725
5836
  { headers: { Authorization: `Bearer ${apiKey}` } }
5726
5837
  );
5727
5838
  if (response.data.success) {
5728
- spinner.succeed(import_chalk31.default.green("Idea Captured! \u{1F4A1}"));
5729
- console.log(import_chalk31.default.dim(`ID: ${response.data.data?.id || "Saved"}`));
5839
+ spinner.succeed(import_chalk32.default.green("Idea Captured! \u{1F4A1}"));
5840
+ console.log(import_chalk32.default.dim(`ID: ${response.data.data?.id || "Saved"}`));
5730
5841
  } else {
5731
5842
  throw new Error(response.data.error);
5732
5843
  }
5733
5844
  } catch (e) {
5734
5845
  const errorDetail = e.response?.data?.error || e.message;
5735
- console.error(import_chalk31.default.red(`
5846
+ console.error(import_chalk32.default.red(`
5736
5847
  Failed to capture idea: ${errorDetail}`));
5737
5848
  }
5738
5849
  });
@@ -5741,10 +5852,10 @@ Failed to capture idea: ${errorDetail}`));
5741
5852
  // src/commands/release.ts
5742
5853
  init_cjs_shims();
5743
5854
  var import_commander21 = require("commander");
5744
- var import_chalk32 = __toESM(require("chalk"), 1);
5855
+ var import_chalk33 = __toESM(require("chalk"), 1);
5745
5856
  var import_ora14 = __toESM(require("ora"), 1);
5746
5857
  var import_inquirer6 = __toESM(require("inquirer"), 1);
5747
- var import_promises23 = __toESM(require("fs/promises"), 1);
5858
+ var import_promises22 = __toESM(require("fs/promises"), 1);
5748
5859
  var import_path27 = __toESM(require("path"), 1);
5749
5860
  init_config();
5750
5861
 
@@ -8616,7 +8727,7 @@ function versionParser(stdOut) {
8616
8727
  }
8617
8728
  var NOT_INSTALLED;
8618
8729
  var parsers7;
8619
- var init_version = __esm2({
8730
+ var init_version2 = __esm2({
8620
8731
  "src/lib/tasks/version.ts"() {
8621
8732
  "use strict";
8622
8733
  init_utils();
@@ -8664,7 +8775,7 @@ var init_simple_git_api = __esm2({
8664
8775
  init_show();
8665
8776
  init_status();
8666
8777
  init_task();
8667
- init_version();
8778
+ init_version2();
8668
8779
  init_utils();
8669
8780
  SimpleGitApi = class {
8670
8781
  constructor(_executor) {
@@ -10310,7 +10421,7 @@ function createReleaseCommand() {
10310
10421
  }
10311
10422
  spinner.text = "Scanning completed tasks...";
10312
10423
  const pkgPath = import_path27.default.resolve(process.cwd(), "package.json");
10313
- const pkgContent = await import_promises23.default.readFile(pkgPath, "utf-8");
10424
+ const pkgContent = await import_promises22.default.readFile(pkgPath, "utf-8");
10314
10425
  const pkg2 = JSON.parse(pkgContent);
10315
10426
  const currentVersion = pkg2.version;
10316
10427
  const [major, minor, patch] = currentVersion.split(".").map(Number);
@@ -10318,7 +10429,7 @@ function createReleaseCommand() {
10318
10429
  if (type === "major") newVersion = `${major + 1}.0.0`;
10319
10430
  if (type === "minor") newVersion = `${major}.${minor + 1}.0`;
10320
10431
  if (type === "patch") newVersion = `${major}.${minor}.${patch + 1}`;
10321
- spinner.succeed(`Bumping ${pkg2.name} from ${import_chalk32.default.dim(currentVersion)} to ${import_chalk32.default.green(newVersion)}`);
10432
+ spinner.succeed(`Bumping ${pkg2.name} from ${import_chalk33.default.dim(currentVersion)} to ${import_chalk33.default.green(newVersion)}`);
10322
10433
  const { confirm } = await import_inquirer6.default.prompt([{
10323
10434
  type: "confirm",
10324
10435
  name: "confirm",
@@ -10330,7 +10441,7 @@ function createReleaseCommand() {
10330
10441
  return;
10331
10442
  }
10332
10443
  pkg2.version = newVersion;
10333
- await import_promises23.default.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
10444
+ await import_promises22.default.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
10334
10445
  const changelogPath = import_path27.default.resolve(process.cwd(), "CHANGELOG.md");
10335
10446
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
10336
10447
  const entry = `
@@ -10338,9 +10449,9 @@ function createReleaseCommand() {
10338
10449
  - Automated release via Rigstate.
10339
10450
  `;
10340
10451
  try {
10341
- await import_promises23.default.appendFile(changelogPath, entry);
10452
+ await import_promises22.default.appendFile(changelogPath, entry);
10342
10453
  } catch {
10343
- await import_promises23.default.writeFile(changelogPath, "# Changelog\n" + entry);
10454
+ await import_promises22.default.writeFile(changelogPath, "# Changelog\n" + entry);
10344
10455
  }
10345
10456
  spinner.start("Tagging and pushing...");
10346
10457
  await git.add(["package.json", "CHANGELOG.md"]);
@@ -10348,7 +10459,7 @@ function createReleaseCommand() {
10348
10459
  await git.addTag(`v${newVersion}`);
10349
10460
  await git.push();
10350
10461
  await git.pushTags();
10351
- spinner.succeed(import_chalk32.default.bold.green(`\u{1F680} Release v${newVersion} shipped!`));
10462
+ spinner.succeed(import_chalk33.default.bold.green(`\u{1F680} Release v${newVersion} shipped!`));
10352
10463
  } catch (e) {
10353
10464
  spinner.fail(e.message);
10354
10465
  }
@@ -10365,7 +10476,7 @@ function getContext3() {
10365
10476
  // src/commands/roadmap.ts
10366
10477
  init_cjs_shims();
10367
10478
  var import_commander22 = require("commander");
10368
- var import_chalk33 = __toESM(require("chalk"), 1);
10479
+ var import_chalk34 = __toESM(require("chalk"), 1);
10369
10480
  var import_ora15 = __toESM(require("ora"), 1);
10370
10481
  var import_axios23 = __toESM(require("axios"), 1);
10371
10482
  init_config();
@@ -10377,7 +10488,7 @@ function createRoadmapCommand() {
10377
10488
  const apiUrl = getApiUrl();
10378
10489
  const projectId = getProjectId();
10379
10490
  if (!projectId) {
10380
- spinner.fail(import_chalk33.default.red('Project context missing. Run "rigstate link".'));
10491
+ spinner.fail(import_chalk34.default.red('Project context missing. Run "rigstate link".'));
10381
10492
  return;
10382
10493
  }
10383
10494
  const response = await import_axios23.default.get(
@@ -10390,11 +10501,11 @@ function createRoadmapCommand() {
10390
10501
  const tasks = response.data.data.roadmap || [];
10391
10502
  spinner.stop();
10392
10503
  if (tasks.length === 0) {
10393
- console.log(import_chalk33.default.yellow("\nRoadmap is empty. Use the web UI to define your journey."));
10504
+ console.log(import_chalk34.default.yellow("\nRoadmap is empty. Use the web UI to define your journey."));
10394
10505
  return;
10395
10506
  }
10396
- console.log("\n" + import_chalk33.default.bold.underline("\u{1F6F0}\uFE0F TACTICAL OVERVIEW: PROJECT ROADMAP"));
10397
- console.log(import_chalk33.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10507
+ console.log("\n" + import_chalk34.default.bold.underline("\u{1F6F0}\uFE0F TACTICAL OVERVIEW: PROJECT ROADMAP"));
10508
+ console.log(import_chalk34.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10398
10509
  const columns = {
10399
10510
  "IN_PROGRESS": [],
10400
10511
  "ACTIVE": [],
@@ -10406,14 +10517,14 @@ function createRoadmapCommand() {
10406
10517
  columns[t.status].push(t);
10407
10518
  }
10408
10519
  });
10409
- displayColumn("\u{1F525} IN PROGRESS", columns.IN_PROGRESS, import_chalk33.default.yellow);
10410
- displayColumn("\u25B6\uFE0F ACTIVE / NEXT", columns.ACTIVE, import_chalk33.default.green);
10411
- displayColumn("\u{1F512} LOCKED", columns.LOCKED, import_chalk33.default.blue);
10412
- displayColumn("\u23F3 PENDING", columns.PENDING, import_chalk33.default.gray);
10413
- console.log(import_chalk33.default.dim("\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10414
- console.log(import_chalk33.default.dim(`Total: ${tasks.length} tasks | Run "rigstate work" to start coding.`));
10520
+ displayColumn("\u{1F525} IN PROGRESS", columns.IN_PROGRESS, import_chalk34.default.yellow);
10521
+ displayColumn("\u25B6\uFE0F ACTIVE / NEXT", columns.ACTIVE, import_chalk34.default.green);
10522
+ displayColumn("\u{1F512} LOCKED", columns.LOCKED, import_chalk34.default.blue);
10523
+ displayColumn("\u23F3 PENDING", columns.PENDING, import_chalk34.default.gray);
10524
+ console.log(import_chalk34.default.dim("\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10525
+ console.log(import_chalk34.default.dim(`Total: ${tasks.length} tasks | Run "rigstate work" to start coding.`));
10415
10526
  } catch (e) {
10416
- spinner.fail(import_chalk33.default.red(`
10527
+ spinner.fail(import_chalk34.default.red(`
10417
10528
  Failed to fetch roadmap: ${e.message}`));
10418
10529
  }
10419
10530
  });
@@ -10424,15 +10535,15 @@ function displayColumn(title, items, color) {
10424
10535
  ${color.bold(title)}`);
10425
10536
  items.sort((a, b) => a.step_number - b.step_number).forEach((item) => {
10426
10537
  const id = `T-${item.step_number}`.padEnd(8);
10427
- const priority = item.priority === "MVP" ? import_chalk33.default.magenta(" [MVP]") : "";
10428
- console.log(` ${color("\u2022")} ${import_chalk33.default.bold(id)} ${item.title}${priority}`);
10538
+ const priority = item.priority === "MVP" ? import_chalk34.default.magenta(" [MVP]") : "";
10539
+ console.log(` ${color("\u2022")} ${import_chalk34.default.bold(id)} ${item.title}${priority}`);
10429
10540
  });
10430
10541
  }
10431
10542
 
10432
10543
  // src/commands/council.ts
10433
10544
  init_cjs_shims();
10434
10545
  var import_commander23 = require("commander");
10435
- var import_chalk34 = __toESM(require("chalk"), 1);
10546
+ var import_chalk35 = __toESM(require("chalk"), 1);
10436
10547
  var import_ora16 = __toESM(require("ora"), 1);
10437
10548
  var import_inquirer7 = __toESM(require("inquirer"), 1);
10438
10549
  init_config();
@@ -10444,7 +10555,7 @@ function createCouncilCommand() {
10444
10555
  const apiUrl = getApiUrl();
10445
10556
  const projectId = getProjectId();
10446
10557
  if (!projectId) {
10447
- console.error(import_chalk34.default.red('Project context missing. Run "rigstate link".'));
10558
+ console.error(import_chalk35.default.red('Project context missing. Run "rigstate link".'));
10448
10559
  return;
10449
10560
  }
10450
10561
  let sessionTopic = topic;
@@ -10456,25 +10567,25 @@ function createCouncilCommand() {
10456
10567
  }]);
10457
10568
  sessionTopic = ans.topic;
10458
10569
  }
10459
- console.log(import_chalk34.default.bold.magenta("\n\u2696\uFE0F CONVENING THE COUNCIL OF SOVEREIGNTY\n"));
10460
- console.log(import_chalk34.default.dim(`Topic: ${sessionTopic}`));
10461
- console.log(import_chalk34.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10462
- console.log(import_chalk34.default.yellow("\n\u{1F9E0} Frank (Architect): Analyzing alignment with Project DNA..."));
10570
+ console.log(import_chalk35.default.bold.magenta("\n\u2696\uFE0F CONVENING THE COUNCIL OF SOVEREIGNTY\n"));
10571
+ console.log(import_chalk35.default.dim(`Topic: ${sessionTopic}`));
10572
+ console.log(import_chalk35.default.dim("\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10573
+ console.log(import_chalk35.default.yellow("\n\u{1F9E0} Frank (Architect): Analyzing alignment with Project DNA..."));
10463
10574
  await sleep(1500);
10464
- console.log(import_chalk34.default.gray(' "This decision affects our backend scalability. I recommend caution."'));
10465
- console.log(import_chalk34.default.blue("\n\u{1F6E1}\uFE0F Sigrid (Curator): Checking historical precedents..."));
10575
+ console.log(import_chalk35.default.gray(' "This decision affects our backend scalability. I recommend caution."'));
10576
+ console.log(import_chalk35.default.blue("\n\u{1F6E1}\uFE0F Sigrid (Curator): Checking historical precedents..."));
10466
10577
  await sleep(1500);
10467
- console.log(import_chalk34.default.gray(` "Similar patterns in other projects led to technical debt. Let's review RLS."`));
10468
- console.log(import_chalk34.default.green("\n\u{1F4D0} Einar (Analyst): Scanning dependency impact..."));
10578
+ console.log(import_chalk35.default.gray(` "Similar patterns in other projects led to technical debt. Let's review RLS."`));
10579
+ console.log(import_chalk35.default.green("\n\u{1F4D0} Einar (Analyst): Scanning dependency impact..."));
10469
10580
  await sleep(1500);
10470
- console.log(import_chalk34.default.gray(' "Implementation will require updating 3 core services."'));
10471
- console.log(import_chalk34.default.bold.white("\n\u{1F4CB} [FINAL DECISION RECORD]"));
10472
- console.log(import_chalk34.default.white(" Status: Approved with conditions"));
10473
- console.log(import_chalk34.default.white(" Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance."));
10474
- console.log(import_chalk34.default.dim("\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10475
- console.log(import_chalk34.default.green("\u2705 Decision saved to Project Brain (ADR-102)"));
10581
+ console.log(import_chalk35.default.gray(' "Implementation will require updating 3 core services."'));
10582
+ console.log(import_chalk35.default.bold.white("\n\u{1F4CB} [FINAL DECISION RECORD]"));
10583
+ console.log(import_chalk35.default.white(" Status: Approved with conditions"));
10584
+ console.log(import_chalk35.default.white(" Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance."));
10585
+ console.log(import_chalk35.default.dim("\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
10586
+ console.log(import_chalk35.default.green("\u2705 Decision saved to Project Brain (ADR-102)"));
10476
10587
  } catch (e) {
10477
- console.error(import_chalk34.default.red(`
10588
+ console.error(import_chalk35.default.red(`
10478
10589
  Council session aborted: ${e.message}`));
10479
10590
  }
10480
10591
  });
@@ -10483,12 +10594,8 @@ function sleep(ms) {
10483
10594
  return new Promise((resolve) => setTimeout(resolve, ms));
10484
10595
  }
10485
10596
 
10486
- // src/utils/version.ts
10487
- init_cjs_shims();
10488
- async function checkVersion() {
10489
- }
10490
-
10491
10597
  // src/index.ts
10598
+ init_version();
10492
10599
  var import_dotenv = __toESM(require("dotenv"), 1);
10493
10600
  var pkg = require_package();
10494
10601
  import_dotenv.default.config();
@@ -10522,19 +10629,19 @@ program.hook("preAction", async () => {
10522
10629
  });
10523
10630
  program.on("--help", () => {
10524
10631
  console.log("");
10525
- console.log(import_chalk35.default.bold("Examples:"));
10632
+ console.log(import_chalk36.default.bold("Examples:"));
10526
10633
  console.log("");
10527
- console.log(import_chalk35.default.cyan(" $ rigstate login sk_rigstate_your_api_key"));
10528
- console.log(import_chalk35.default.dim(" Authenticate with your Rigstate API key"));
10634
+ console.log(import_chalk36.default.cyan(" $ rigstate login sk_rigstate_your_api_key"));
10635
+ console.log(import_chalk36.default.dim(" Authenticate with your Rigstate API key"));
10529
10636
  console.log("");
10530
- console.log(import_chalk35.default.cyan(" $ rigstate scan"));
10531
- console.log(import_chalk35.default.dim(" Scan the current directory"));
10637
+ console.log(import_chalk36.default.cyan(" $ rigstate scan"));
10638
+ console.log(import_chalk36.default.dim(" Scan the current directory"));
10532
10639
  console.log("");
10533
- console.log(import_chalk35.default.cyan(" $ rigstate scan ./src --project abc123"));
10534
- console.log(import_chalk35.default.dim(" Scan a specific directory with project ID"));
10640
+ console.log(import_chalk36.default.cyan(" $ rigstate scan ./src --project abc123"));
10641
+ console.log(import_chalk36.default.dim(" Scan a specific directory with project ID"));
10535
10642
  console.log("");
10536
- console.log(import_chalk35.default.cyan(" $ rigstate scan --json"));
10537
- console.log(import_chalk35.default.dim(" Output results in JSON format (useful for IDE extensions)"));
10643
+ console.log(import_chalk36.default.cyan(" $ rigstate scan --json"));
10644
+ console.log(import_chalk36.default.dim(" Output results in JSON format (useful for IDE extensions)"));
10538
10645
  console.log("");
10539
10646
  });
10540
10647
  program.parse(process.argv);