@rigstate/cli 0.7.34 → 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,16 +346,16 @@ 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
  }
@@ -275,7 +394,7 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false, versi
275
394
  const project = projectRes.data.data.projects[0];
276
395
  spinner.text = `Syncing rules for ${project.name}...`;
277
396
  if (dryRun) {
278
- 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}`));
279
398
  return true;
280
399
  }
281
400
  const syncResponse = await import_axios2.default.post(`${apiUrl}/api/v1/rules/sync`, {
@@ -285,9 +404,9 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false, versi
285
404
  });
286
405
  if (syncResponse.data.success) {
287
406
  if (syncResponse.data.data.github_synced) {
288
- 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`));
289
408
  } else {
290
- 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)`));
291
410
  }
292
411
  const files = syncResponse.data.data.files;
293
412
  if (files && Array.isArray(files)) {
@@ -298,7 +417,7 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false, versi
298
417
  await fs26.mkdir(path28.dirname(filePath), { recursive: true });
299
418
  await fs26.writeFile(filePath, file.content, "utf-8");
300
419
  }
301
- 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/`));
302
421
  try {
303
422
  const masterPath = path28.join(process.cwd(), ".cursorrules");
304
423
  let masterContent = "";
@@ -333,20 +452,20 @@ ${END_MARKER}`;
333
452
  ${governanceBlock}` : governanceBlock;
334
453
  }
335
454
  await fs26.writeFile(masterPath, newContent, "utf-8");
336
- 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)"));
337
456
  } catch (e) {
338
- 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}`));
339
458
  }
340
459
  }
341
460
  console.log("");
342
- console.log(import_chalk3.default.cyan("\u{1F6E1}\uFE0F Frank Protocol v1.0 has been injected into the rules engine."));
343
- 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."));
344
463
  } else {
345
- 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"}`));
346
465
  success = false;
347
466
  }
348
467
  } catch (e) {
349
- spinner.fail(import_chalk3.default.red(`Sync failed: ${e.message}`));
468
+ spinner.fail(import_chalk4.default.red(`Sync failed: ${e.message}`));
350
469
  success = false;
351
470
  }
352
471
  return success;
@@ -358,25 +477,25 @@ function createSyncRulesCommand() {
358
477
  try {
359
478
  apiKey = getApiKey();
360
479
  } catch (e) {
361
- 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.'));
362
481
  return;
363
482
  }
364
483
  const apiUrl = getApiUrl();
365
484
  if (options.project) {
366
485
  await syncProjectRules(options.project, apiKey, apiUrl, options.dryRun);
367
486
  } else {
368
- 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)"));
369
488
  }
370
489
  });
371
490
  return syncRules;
372
491
  }
373
- var import_commander3, import_chalk3, import_ora2, import_axios2;
492
+ var import_commander3, import_chalk4, import_ora2, import_axios2;
374
493
  var init_sync_rules = __esm({
375
494
  "src/commands/sync-rules.ts"() {
376
495
  "use strict";
377
496
  init_cjs_shims();
378
497
  import_commander3 = require("commander");
379
- import_chalk3 = __toESM(require("chalk"), 1);
498
+ import_chalk4 = __toESM(require("chalk"), 1);
380
499
  import_ora2 = __toESM(require("ora"), 1);
381
500
  init_config();
382
501
  import_axios2 = __toESM(require("axios"), 1);
@@ -407,28 +526,28 @@ async function suggestNextMove(projectId, apiKey, apiUrl) {
407
526
  if (tasks.length === 0) return;
408
527
  const nextTask = tasks[0];
409
528
  console.log("");
410
- console.log(import_chalk4.default.bold("\u{1F3AF} TACTICAL INTELLIGENCE"));
411
- 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"));
412
- console.log(`${import_chalk4.default.bold("Active Phase:")} Implementation`);
413
- 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)}`);
414
533
  if (nextTask.role) {
415
- 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)}`);
416
535
  }
417
536
  console.log("");
418
- console.log(import_chalk4.default.yellow("SUGGESTED NEXT MOVE:"));
419
- console.log(import_chalk4.default.white(`> rigstate work start ${nextTask.id} `) + import_chalk4.default.dim("(Start this task)"));
420
- console.log(import_chalk4.default.white(`> rigstate chat "How do I solve T-${nextTask.step_number}?" `) + import_chalk4.default.dim("(Ask Architect)"));
421
- 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"));
422
541
  console.log("");
423
542
  } catch (e) {
424
543
  }
425
544
  }
426
- var import_chalk4, import_axios3;
545
+ var import_chalk5, import_axios3;
427
546
  var init_suggest = __esm({
428
547
  "src/commands/suggest.ts"() {
429
548
  "use strict";
430
549
  init_cjs_shims();
431
- import_chalk4 = __toESM(require("chalk"), 1);
550
+ import_chalk5 = __toESM(require("chalk"), 1);
432
551
  import_axios3 = __toESM(require("axios"), 1);
433
552
  }
434
553
  });
@@ -461,18 +580,18 @@ async function provisionSkills(apiUrl, apiKey, projectId, rootDir) {
461
580
  }
462
581
  } catch (e) {
463
582
  const msg = e.response?.data?.error || e.message;
464
- 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)`));
465
584
  }
466
585
  if (skills.length === 0) {
467
586
  const { getRigstateStandardSkills } = await import("@rigstate/rules-engine");
468
587
  const coreSkills = getRigstateStandardSkills();
469
588
  skills.push(...coreSkills);
470
589
  }
471
- const skillsDir = import_path6.default.join(rootDir, ".agent", "skills");
472
- 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 });
473
592
  for (const skill of skills) {
474
- const skillDir = import_path6.default.join(skillsDir, skill.name);
475
- 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 });
476
595
  const skillContent = `---
477
596
  name: ${skill.name}
478
597
  description: ${skill.description}
@@ -485,10 +604,10 @@ ${skill.content}
485
604
 
486
605
  ---
487
606
  *Provisioned by Rigstate CLI. Do not modify manually.*`;
488
- const skillPath = import_path6.default.join(skillDir, "SKILL.md");
489
- 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");
490
609
  }
491
- 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/`));
492
611
  return skills;
493
612
  }
494
613
  function generateSkillsDiscoveryBlock(skills) {
@@ -503,16 +622,16 @@ ${skillBlocks}
503
622
  </available_skills>`;
504
623
  }
505
624
  async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
506
- const rulesPath = import_path6.default.join(rootDir, ".cursorrules");
625
+ const rulesPath = import_path8.default.join(rootDir, ".cursorrules");
507
626
  let rulesContent = "";
508
627
  try {
509
- rulesContent = await import_promises6.default.readFile(rulesPath, "utf-8");
628
+ rulesContent = await import_promises7.default.readFile(rulesPath, "utf-8");
510
629
  } catch (e) {
511
630
  return false;
512
631
  }
513
632
  const isProvisioned = rulesContent.includes(`<name>${skillId}</name>`) || rulesContent.includes(`.agent/skills/${skillId}`);
514
633
  if (isProvisioned) return false;
515
- console.log(import_chalk8.default.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
634
+ console.log(import_chalk9.default.yellow(` \u26A1 JIT PROVISIONING: Injecting ${skillId}...`));
516
635
  try {
517
636
  const skills = await provisionSkills(apiUrl, apiKey, projectId, rootDir);
518
637
  const skillsBlock = generateSkillsDiscoveryBlock(skills);
@@ -527,22 +646,22 @@ async function jitProvisionSkill(skillId, apiUrl, apiKey, projectId, rootDir) {
527
646
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
528
647
  }
529
648
  }
530
- await import_promises6.default.writeFile(rulesPath, rulesContent, "utf-8");
649
+ await import_promises7.default.writeFile(rulesPath, rulesContent, "utf-8");
531
650
  return true;
532
651
  } catch (e) {
533
- 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}`));
534
653
  return false;
535
654
  }
536
655
  }
537
- var import_axios6, import_promises6, import_path6, import_chalk8;
656
+ var import_axios6, import_promises7, import_path8, import_chalk9;
538
657
  var init_skills_provisioner = __esm({
539
658
  "src/utils/skills-provisioner.ts"() {
540
659
  "use strict";
541
660
  init_cjs_shims();
542
661
  import_axios6 = __toESM(require("axios"), 1);
543
- import_promises6 = __toESM(require("fs/promises"), 1);
544
- import_path6 = __toESM(require("path"), 1);
545
- 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);
546
665
  }
547
666
  });
548
667
 
@@ -558,8 +677,8 @@ __export(governance_exports, {
558
677
  });
559
678
  async function getGovernanceConfig(rootDir = process.cwd()) {
560
679
  try {
561
- const configPath = import_path7.default.join(rootDir, "rigstate.config.json");
562
- 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");
563
682
  const userConfig = JSON.parse(content);
564
683
  return {
565
684
  governance: {
@@ -573,50 +692,50 @@ async function getGovernanceConfig(rootDir = process.cwd()) {
573
692
  }
574
693
  async function getSessionState(rootDir = process.cwd()) {
575
694
  try {
576
- const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
577
- 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");
578
697
  return JSON.parse(content);
579
698
  } catch (e) {
580
699
  return DEFAULT_SESSION;
581
700
  }
582
701
  }
583
702
  async function setSoftLock(reason, violationId, rootDir = process.cwd()) {
584
- const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
703
+ const sessionPath = import_path9.default.join(rootDir, ".rigstate", "session.json");
585
704
  const state = {
586
705
  status: "SOFT_LOCK",
587
706
  active_violation: violationId,
588
707
  lock_reason: reason,
589
708
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
590
709
  };
591
- await import_promises7.default.mkdir(import_path7.default.dirname(sessionPath), { recursive: true });
592
- 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");
593
712
  }
594
713
  async function clearSoftLock(rootDir = process.cwd()) {
595
- const sessionPath = import_path7.default.join(rootDir, ".rigstate", "session.json");
714
+ const sessionPath = import_path9.default.join(rootDir, ".rigstate", "session.json");
596
715
  const state = {
597
716
  ...DEFAULT_SESSION,
598
717
  last_updated: (/* @__PURE__ */ new Date()).toISOString()
599
718
  };
600
- await import_promises7.default.mkdir(import_path7.default.dirname(sessionPath), { recursive: true });
601
- 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");
602
721
  }
603
722
  async function performOverride(violationId, reason, rootDir = process.cwd()) {
604
723
  const config2 = await getGovernanceConfig(rootDir);
605
724
  if (!config2.governance.allow_overrides) {
606
- 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."));
607
726
  return false;
608
727
  }
609
728
  await clearSoftLock(rootDir);
610
729
  return true;
611
730
  }
612
- 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;
613
732
  var init_governance = __esm({
614
733
  "src/utils/governance.ts"() {
615
734
  "use strict";
616
735
  init_cjs_shims();
617
- import_promises7 = __toESM(require("fs/promises"), 1);
618
- import_path7 = __toESM(require("path"), 1);
619
- 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);
620
739
  InterventionLevel = /* @__PURE__ */ ((InterventionLevel2) => {
621
740
  InterventionLevel2[InterventionLevel2["GHOST"] = 0] = "GHOST";
622
741
  InterventionLevel2[InterventionLevel2["NUDGE"] = 1] = "NUDGE";
@@ -645,16 +764,16 @@ __export(watchdog_exports, {
645
764
  });
646
765
  async function countLines(filePath) {
647
766
  try {
648
- const content = await import_promises8.default.readFile(filePath, "utf-8");
767
+ const content = await import_promises9.default.readFile(filePath, "utf-8");
649
768
  return content.split("\n").length;
650
769
  } catch (e) {
651
770
  return 0;
652
771
  }
653
772
  }
654
773
  async function getFiles(dir, extension) {
655
- const entries = await import_promises8.default.readdir(dir, { withFileTypes: true });
774
+ const entries = await import_promises9.default.readdir(dir, { withFileTypes: true });
656
775
  const files = await Promise.all(entries.map(async (entry) => {
657
- const res = import_path8.default.resolve(dir, entry.name);
776
+ const res = import_path10.default.resolve(dir, entry.name);
658
777
  if (entry.isDirectory()) {
659
778
  if (entry.name === "node_modules" || entry.name === ".git" || entry.name === ".next" || entry.name === "dist") return [];
660
779
  return getFiles(res, extension);
@@ -682,8 +801,8 @@ async function fetchRulesFromApi(projectId) {
682
801
  }
683
802
  } catch (error) {
684
803
  try {
685
- const cachePath = import_path8.default.join(process.cwd(), CACHE_FILE);
686
- 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");
687
806
  const cached = JSON.parse(content);
688
807
  if (cached.settings) {
689
808
  return {
@@ -702,7 +821,7 @@ async function fetchRulesFromApi(projectId) {
702
821
  };
703
822
  }
704
823
  async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
705
- 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..."));
706
825
  let lmax = settings.lmax || DEFAULT_LMAX;
707
826
  let lmaxWarning = settings.lmax_warning || DEFAULT_LMAX_WARNING;
708
827
  let ruleSource = settings.lmax ? "Settings (Passed)" : "Default";
@@ -712,47 +831,47 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
712
831
  lmaxWarning = apiRules.lmaxWarning;
713
832
  ruleSource = apiRules.source;
714
833
  }
715
- 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}`));
716
835
  const targetExtensions = [".ts", ".tsx"];
717
836
  let scanTarget = rootPath;
718
- const webSrc = import_path8.default.join(rootPath, "apps", "web", "src");
837
+ const webSrc = import_path10.default.join(rootPath, "apps", "web", "src");
719
838
  try {
720
- await import_promises8.default.access(webSrc);
839
+ await import_promises9.default.access(webSrc);
721
840
  scanTarget = webSrc;
722
841
  } catch {
723
842
  }
724
- 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)}`));
725
844
  const files = await getFiles(scanTarget, targetExtensions);
726
845
  let violations = 0;
727
846
  let warnings = 0;
728
847
  const results = [];
729
848
  for (const file of files) {
730
849
  const lines = await countLines(file);
731
- const relPath = import_path8.default.relative(rootPath, file);
850
+ const relPath = import_path10.default.relative(rootPath, file);
732
851
  if (lines > lmax) {
733
852
  results.push({ file: relPath, lines, status: "VIOLATION" });
734
853
  violations++;
735
- 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})`));
736
855
  } else if (lines > lmaxWarning) {
737
856
  results.push({ file: relPath, lines, status: "WARNING" });
738
857
  warnings++;
739
- 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})`));
740
859
  }
741
860
  }
742
861
  if (violations === 0 && warnings === 0) {
743
- 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.`));
744
863
  } else {
745
- console.log("\n" + import_chalk10.default.bold("Summary:"));
746
- console.log(import_chalk10.default.red(`Violations: ${violations}`));
747
- 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}`));
748
867
  const { getGovernanceConfig: getGovernanceConfig2, setSoftLock: setSoftLock2, InterventionLevel: InterventionLevel2 } = await Promise.resolve().then(() => (init_governance(), governance_exports));
749
868
  const { governance } = await getGovernanceConfig2(rootPath);
750
- 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})`));
751
870
  if (violations > 0) {
752
- 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."));
753
872
  if (governance.intervention_level >= InterventionLevel2.SENTINEL) {
754
- console.log(import_chalk10.default.red.bold("\u{1F6D1} SENTINEL MODE: Session SOFT_LOCKED until resolved."));
755
- 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.'));
756
875
  await setSoftLock2("Sentinel Mode: Governance Violations Detected", "ARC-VIOLATION", rootPath);
757
876
  }
758
877
  }
@@ -775,20 +894,20 @@ async function runGuardianWatchdog(rootPath, settings = {}, projectId) {
775
894
  }, {
776
895
  headers: { Authorization: `Bearer ${apiKey}` }
777
896
  });
778
- 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."));
779
898
  } catch (e) {
780
- 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")));
781
900
  }
782
901
  }
783
902
  }
784
- 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;
785
904
  var init_watchdog = __esm({
786
905
  "src/utils/watchdog.ts"() {
787
906
  "use strict";
788
907
  init_cjs_shims();
789
- import_promises8 = __toESM(require("fs/promises"), 1);
790
- import_path8 = __toESM(require("path"), 1);
791
- 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);
792
911
  import_axios7 = __toESM(require("axios"), 1);
793
912
  init_config();
794
913
  DEFAULT_LMAX = 400;
@@ -1735,32 +1854,32 @@ var require_package = __commonJS({
1735
1854
  // src/index.ts
1736
1855
  init_cjs_shims();
1737
1856
  var import_commander24 = require("commander");
1738
- var import_chalk35 = __toESM(require("chalk"), 1);
1857
+ var import_chalk36 = __toESM(require("chalk"), 1);
1739
1858
 
1740
1859
  // src/commands/login.ts
1741
1860
  init_cjs_shims();
1742
1861
  var import_commander = require("commander");
1743
- var import_chalk = __toESM(require("chalk"), 1);
1862
+ var import_chalk2 = __toESM(require("chalk"), 1);
1744
1863
  init_config();
1745
1864
  function createLoginCommand() {
1746
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) => {
1747
1866
  try {
1748
1867
  if (!apiKey || !apiKey.startsWith("sk_rigstate_")) {
1749
- console.error(import_chalk.default.red("\u274C Invalid API key format"));
1750
- 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_"'));
1751
1870
  process.exit(1);
1752
1871
  }
1753
1872
  setApiKey(apiKey);
1754
- console.log(import_chalk.default.green("\u2705 Successfully logged in!"));
1873
+ console.log(import_chalk2.default.green("\u2705 Successfully logged in!"));
1755
1874
  console.log(
1756
- import_chalk.default.dim(
1875
+ import_chalk2.default.dim(
1757
1876
  `
1758
1877
  Your API key has been securely stored. You can now use "rigstate scan" to audit your code.`
1759
1878
  )
1760
1879
  );
1761
- console.log(import_chalk.default.bold("\n\u{1F916} Cursor MCP Configuration"));
1762
- console.log(import_chalk.default.dim("Copy and paste this into Cursor Settings -> Features -> MCP:"));
1763
- 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(`
1764
1883
  {
1765
1884
  "mcpServers": {
1766
1885
  "rigstate": {
@@ -1777,7 +1896,7 @@ Your API key has been securely stored. You can now use "rigstate scan" to audit
1777
1896
  }`));
1778
1897
  } catch (error) {
1779
1898
  console.error(
1780
- import_chalk.default.red("\u274C Login failed:"),
1899
+ import_chalk2.default.red("\u274C Login failed:"),
1781
1900
  error instanceof Error ? error.message : "Unknown error"
1782
1901
  );
1783
1902
  process.exit(1);
@@ -1788,25 +1907,25 @@ Your API key has been securely stored. You can now use "rigstate scan" to audit
1788
1907
  // src/commands/link.ts
1789
1908
  init_cjs_shims();
1790
1909
  var import_commander4 = require("commander");
1791
- var import_promises2 = __toESM(require("fs/promises"), 1);
1792
- var import_path2 = __toESM(require("path"), 1);
1793
- 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);
1794
1913
  var import_os = __toESM(require("os"), 1);
1795
1914
  init_config();
1796
1915
  function createLinkCommand() {
1797
1916
  return new import_commander4.Command("link").description("Link current directory to a Rigstate project").argument("[projectId]", "Project ID to link").action(async (projectId) => {
1798
1917
  try {
1799
- const globalPath = import_path2.default.join(import_os.default.homedir(), ".rigstate", "config.json");
1800
- 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);
1801
1920
  if (globalData) {
1802
1921
  const config2 = JSON.parse(globalData);
1803
- const cwd = process.cwd();
1804
- if (config2.overrides && config2.overrides[cwd]) {
1805
- const overrideId = config2.overrides[cwd];
1806
- 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}`));
1807
1926
  if (!projectId) projectId = overrideId;
1808
1927
  else if (projectId !== overrideId) {
1809
- 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.`));
1810
1929
  projectId = overrideId;
1811
1930
  }
1812
1931
  }
@@ -1820,16 +1939,16 @@ function createLinkCommand() {
1820
1939
  const apiKey = getApiKey();
1821
1940
  const apiUrl = getApiUrl();
1822
1941
  if (!apiKey) {
1823
- 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.'));
1824
1943
  process.exit(1);
1825
1944
  }
1826
- console.log(import_chalk5.default.dim("Fetching your projects..."));
1945
+ console.log(import_chalk6.default.dim("Fetching your projects..."));
1827
1946
  const axios24 = (await import("axios")).default;
1828
1947
  const response = await axios24.get(`${apiUrl}/api/v1/projects`, {
1829
1948
  headers: { Authorization: `Bearer ${apiKey}` }
1830
1949
  });
1831
1950
  if (!response.data.success || !response.data.data.projects?.length) {
1832
- 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"));
1833
1952
  process.exit(1);
1834
1953
  }
1835
1954
  const choices = response.data.data.projects.map((p) => ({
@@ -1844,54 +1963,49 @@ function createLinkCommand() {
1844
1963
  }]);
1845
1964
  projectId = answer.id;
1846
1965
  } catch (e) {
1847
- 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}`));
1848
1967
  console.error("Please provide project ID manually: rigstate link <id>");
1849
1968
  process.exit(1);
1850
1969
  }
1851
1970
  }
1852
- const manifestPath = import_path2.default.join(process.cwd(), ".rigstate");
1853
- const content = {
1854
- project_id: projectId,
1855
- linked_at: (/* @__PURE__ */ new Date()).toISOString()
1856
- };
1857
- const currentUrl = getApiUrl();
1858
- if (currentUrl !== "https://app.rigstate.com") {
1859
- content.api_url = currentUrl;
1860
- }
1971
+ const cwd = process.cwd();
1861
1972
  try {
1862
- await import_promises2.default.mkdir(import_path2.default.dirname(manifestPath), { recursive: true });
1863
- await import_promises2.default.writeFile(manifestPath, JSON.stringify(content, null, 2), "utf-8");
1864
- console.log(import_chalk5.default.green(`\u2714 Linked to project ID: ${projectId}`));
1865
- 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)}`));
1866
1981
  console.log("");
1867
- console.log(import_chalk5.default.bold("\u{1F916} Rigstate Automation Detected"));
1982
+ console.log(import_chalk6.default.bold("\u{1F916} Rigstate Automation Detected"));
1868
1983
  console.log("");
1869
- const { getApiKey: _getApiKey, getApiUrl: _getApiUrl } = await Promise.resolve().then(() => (init_config(), config_exports));
1870
1984
  const apiKey = getApiKey();
1871
1985
  const apiUrl = getApiUrl();
1872
1986
  if (apiKey) {
1873
- 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..."));
1874
1988
  const { syncEnv: syncEnv2 } = await Promise.resolve().then(() => (init_env(), env_exports));
1875
1989
  await syncEnv2(projectId, apiKey, apiUrl, true);
1876
- console.log(import_chalk5.default.blue("\u{1F9E0} Syncing neural instructions..."));
1990
+ console.log(import_chalk6.default.blue("\u{1F9E0} Syncing neural instructions..."));
1877
1991
  const { syncProjectRules: syncProjectRules2 } = await Promise.resolve().then(() => (init_sync_rules(), sync_rules_exports));
1878
1992
  await syncProjectRules2(projectId, apiKey, apiUrl);
1879
- 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..."));
1880
1994
  await installHooks(process.cwd());
1881
1995
  await hardenGitIgnore(process.cwd());
1882
1996
  console.log("");
1883
- 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."));
1884
1998
  const { suggestNextMove: suggestNextMove2 } = await Promise.resolve().then(() => (init_suggest(), suggest_exports));
1885
1999
  await suggestNextMove2(projectId, apiKey, apiUrl);
1886
2000
  } else {
1887
2001
  console.log("");
1888
- console.log(import_chalk5.default.bold.green("\u{1F680} Link Complete!"));
2002
+ console.log(import_chalk6.default.bold.green("\u{1F680} Link Complete!"));
1889
2003
  }
1890
2004
  } catch (error) {
1891
2005
  if (error.message?.includes("Not authenticated")) {
1892
- 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.'));
1893
2007
  } else {
1894
- 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}`));
1895
2009
  }
1896
2010
  }
1897
2011
  });
@@ -1920,15 +2034,15 @@ async function hardenGitIgnore(cwd) {
1920
2034
  }
1921
2035
  const missing = REQUIRED_IGNORES.filter((line) => !content.includes(line) && !line.startsWith("#"));
1922
2036
  if (missing.length > 0) {
1923
- console.log(import_chalk5.default.dim(" Configuring .gitignore for Rigstate safety..."));
2037
+ console.log(import_chalk6.default.dim(" Configuring .gitignore for Rigstate safety..."));
1924
2038
  const toAppend = "\n\n" + REQUIRED_IGNORES.join("\n") + "\n";
1925
2039
  await fs26.writeFile(ignorePath, content + toAppend, "utf-8");
1926
- console.log(import_chalk5.default.green(" \u2714 .gitignore updated (Artifacts protected)"));
2040
+ console.log(import_chalk6.default.green(" \u2714 .gitignore updated (Artifacts protected)"));
1927
2041
  } else {
1928
- console.log(import_chalk5.default.green(" \u2714 .gitignore already hardened"));
2042
+ console.log(import_chalk6.default.green(" \u2714 .gitignore already hardened"));
1929
2043
  }
1930
2044
  } catch (e) {
1931
- 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}`));
1932
2046
  }
1933
2047
  }
1934
2048
  async function installHooks(cwd) {
@@ -1937,7 +2051,7 @@ async function installHooks(cwd) {
1937
2051
  try {
1938
2052
  await fs26.access(path28.join(cwd, ".git"));
1939
2053
  } catch {
1940
- 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)"));
1941
2055
  return;
1942
2056
  }
1943
2057
  const hooksDir = path28.join(cwd, ".husky");
@@ -1948,7 +2062,7 @@ async function installHooks(cwd) {
1948
2062
  await fs26.access(preCommitPath);
1949
2063
  const content = await fs26.readFile(preCommitPath, "utf-8");
1950
2064
  if (content.includes("rigstate")) {
1951
- console.log(import_chalk5.default.green(" \u2714 Git hooks already active"));
2065
+ console.log(import_chalk6.default.green(" \u2714 Git hooks already active"));
1952
2066
  } else {
1953
2067
  shouldInstall = true;
1954
2068
  }
@@ -1977,10 +2091,10 @@ exit $?
1977
2091
  } else {
1978
2092
  await fs26.writeFile(preCommitPath, PRE_COMMIT_SCRIPT2, { mode: 493 });
1979
2093
  }
1980
- 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)"));
1981
2095
  }
1982
2096
  } catch (e) {
1983
- console.log(import_chalk5.default.dim(" (Skipped hooks: " + e.message + ")"));
2097
+ console.log(import_chalk6.default.dim(" (Skipped hooks: " + e.message + ")"));
1984
2098
  }
1985
2099
  }
1986
2100
  async function fileExists(path28) {
@@ -1996,22 +2110,22 @@ async function fileExists(path28) {
1996
2110
  // src/commands/scan.ts
1997
2111
  init_cjs_shims();
1998
2112
  var import_commander5 = require("commander");
1999
- var import_chalk6 = __toESM(require("chalk"), 1);
2113
+ var import_chalk7 = __toESM(require("chalk"), 1);
2000
2114
  var import_ora3 = __toESM(require("ora"), 1);
2001
2115
  var import_axios4 = __toESM(require("axios"), 1);
2002
2116
  var import_glob = require("glob");
2003
- var import_promises4 = __toESM(require("fs/promises"), 1);
2004
- var import_path4 = __toESM(require("path"), 1);
2117
+ var import_promises5 = __toESM(require("fs/promises"), 1);
2118
+ var import_path6 = __toESM(require("path"), 1);
2005
2119
  init_config();
2006
2120
 
2007
2121
  // src/utils/files.ts
2008
2122
  init_cjs_shims();
2009
- var import_promises3 = __toESM(require("fs/promises"), 1);
2010
- var import_path3 = __toESM(require("path"), 1);
2123
+ var import_promises4 = __toESM(require("fs/promises"), 1);
2124
+ var import_path5 = __toESM(require("path"), 1);
2011
2125
  async function readGitignore(dir) {
2012
- const gitignorePath = import_path3.default.join(dir, ".gitignore");
2126
+ const gitignorePath = import_path5.default.join(dir, ".gitignore");
2013
2127
  try {
2014
- const content = await import_promises3.default.readFile(gitignorePath, "utf-8");
2128
+ const content = await import_promises4.default.readFile(gitignorePath, "utf-8");
2015
2129
  return content.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
2016
2130
  } catch (error) {
2017
2131
  return [];
@@ -2073,7 +2187,7 @@ function isCodeFile(filePath) {
2073
2187
  ".vue",
2074
2188
  ".svelte"
2075
2189
  ];
2076
- const ext = import_path3.default.extname(filePath).toLowerCase();
2190
+ const ext = import_path5.default.extname(filePath).toLowerCase();
2077
2191
  return codeExtensions.includes(ext);
2078
2192
  }
2079
2193
 
@@ -2087,26 +2201,26 @@ function createScanCommand() {
2087
2201
  const projectId = options.project || getProjectId();
2088
2202
  if (!projectId) {
2089
2203
  console.warn(
2090
- import_chalk6.default.yellow(
2204
+ import_chalk7.default.yellow(
2091
2205
  "\u26A0\uFE0F No project ID specified. Use --project <id> or set a default."
2092
2206
  )
2093
2207
  );
2094
2208
  }
2095
- const scanPath = import_path4.default.resolve(process.cwd(), targetPath);
2096
- 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)}...`);
2097
2211
  const gitignorePatterns = await readGitignore(scanPath);
2098
- const pattern = import_path4.default.join(scanPath, "**/*");
2212
+ const pattern = import_path6.default.join(scanPath, "**/*");
2099
2213
  const allFiles = await (0, import_glob.glob)(pattern, {
2100
2214
  nodir: true,
2101
2215
  dot: false,
2102
2216
  ignore: ["**/node_modules/**", "**/.git/**", "**/dist/**", "**/build/**"]
2103
2217
  });
2104
2218
  const codeFiles = allFiles.filter((file) => {
2105
- const relativePath = import_path4.default.relative(scanPath, file);
2219
+ const relativePath = import_path6.default.relative(scanPath, file);
2106
2220
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2107
2221
  });
2108
2222
  if (codeFiles.length === 0) {
2109
- 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."));
2110
2224
  return;
2111
2225
  }
2112
2226
  spinner.text = `Found ${codeFiles.length} files. Scanning...`;
@@ -2115,10 +2229,10 @@ function createScanCommand() {
2115
2229
  const severityCounts = {};
2116
2230
  for (let i = 0; i < codeFiles.length; i++) {
2117
2231
  const filePath = codeFiles[i];
2118
- const relativePath = import_path4.default.relative(scanPath, filePath);
2232
+ const relativePath = import_path6.default.relative(scanPath, filePath);
2119
2233
  spinner.text = `Scanning ${i + 1}/${codeFiles.length}: ${relativePath}`;
2120
2234
  try {
2121
- const content = await import_promises4.default.readFile(filePath, "utf-8");
2235
+ const content = await import_promises5.default.readFile(filePath, "utf-8");
2122
2236
  const response = await import_axios4.default.post(
2123
2237
  `${apiUrl}/api/v1/audit`,
2124
2238
  {
@@ -2154,15 +2268,15 @@ function createScanCommand() {
2154
2268
  }
2155
2269
  } catch (fileError) {
2156
2270
  if (import_axios4.default.isAxiosError(fileError)) {
2157
- console.warn(import_chalk6.default.yellow(`
2271
+ console.warn(import_chalk7.default.yellow(`
2158
2272
  \u26A0\uFE0F Skipping ${relativePath}: ${fileError.message}`));
2159
2273
  } else {
2160
- console.warn(import_chalk6.default.yellow(`
2274
+ console.warn(import_chalk7.default.yellow(`
2161
2275
  \u26A0\uFE0F Error reading ${relativePath}`));
2162
2276
  }
2163
2277
  }
2164
2278
  }
2165
- spinner.succeed(import_chalk6.default.green("\u2705 Scan completed!"));
2279
+ spinner.succeed(import_chalk7.default.green("\u2705 Scan completed!"));
2166
2280
  const aggregatedResponse = {
2167
2281
  results,
2168
2282
  summary: {
@@ -2177,21 +2291,21 @@ function createScanCommand() {
2177
2291
  printPrettyResults(aggregatedResponse);
2178
2292
  }
2179
2293
  } catch (error) {
2180
- spinner.fail(import_chalk6.default.red("\u274C Scan failed"));
2294
+ spinner.fail(import_chalk7.default.red("\u274C Scan failed"));
2181
2295
  if (import_axios4.default.isAxiosError(error)) {
2182
2296
  if (error.response) {
2183
- console.error(import_chalk6.default.red("API Error:"), error.response.data);
2297
+ console.error(import_chalk7.default.red("API Error:"), error.response.data);
2184
2298
  } else if (error.request) {
2185
2299
  console.error(
2186
- import_chalk6.default.red("Network Error:"),
2300
+ import_chalk7.default.red("Network Error:"),
2187
2301
  "Could not reach the API. Is the server running?"
2188
2302
  );
2189
2303
  } else {
2190
- console.error(import_chalk6.default.red("Error:"), error.message);
2304
+ console.error(import_chalk7.default.red("Error:"), error.message);
2191
2305
  }
2192
2306
  } else {
2193
2307
  console.error(
2194
- import_chalk6.default.red("Error:"),
2308
+ import_chalk7.default.red("Error:"),
2195
2309
  error instanceof Error ? error.message : "Unknown error"
2196
2310
  );
2197
2311
  }
@@ -2201,10 +2315,10 @@ function createScanCommand() {
2201
2315
  }
2202
2316
  function printPrettyResults(data) {
2203
2317
  const { results, summary } = data;
2204
- console.log("\n" + import_chalk6.default.bold("\u{1F4CA} Scan Summary"));
2205
- console.log(import_chalk6.default.dim("\u2500".repeat(60)));
2206
- console.log(`Total Files Scanned: ${import_chalk6.default.cyan(summary.total_files)}`);
2207
- 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)}`);
2208
2322
  if (summary.by_severity) {
2209
2323
  console.log("\nIssues by Severity:");
2210
2324
  Object.entries(summary.by_severity).forEach(([severity, count]) => {
@@ -2213,51 +2327,51 @@ function printPrettyResults(data) {
2213
2327
  });
2214
2328
  }
2215
2329
  if (results && results.length > 0) {
2216
- console.log("\n" + import_chalk6.default.bold("\u{1F50D} Detailed Results"));
2217
- 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)));
2218
2332
  results.forEach((result) => {
2219
2333
  if (result.issues && result.issues.length > 0) {
2220
2334
  console.log(`
2221
- ${import_chalk6.default.bold(result.file_path)}`);
2335
+ ${import_chalk7.default.bold(result.file_path)}`);
2222
2336
  result.issues.forEach((issue) => {
2223
2337
  const severityColor = getSeverityColor(issue.severity);
2224
- const lineInfo = issue.line ? import_chalk6.default.dim(`:${issue.line}`) : "";
2338
+ const lineInfo = issue.line ? import_chalk7.default.dim(`:${issue.line}`) : "";
2225
2339
  console.log(
2226
2340
  ` ${severityColor(`[${issue.severity.toUpperCase()}]`)} ${issue.type}${lineInfo}`
2227
2341
  );
2228
- console.log(` ${import_chalk6.default.dim(issue.message)}`);
2342
+ console.log(` ${import_chalk7.default.dim(issue.message)}`);
2229
2343
  });
2230
2344
  }
2231
2345
  });
2232
2346
  }
2233
- console.log("\n" + import_chalk6.default.dim("\u2500".repeat(60)));
2347
+ console.log("\n" + import_chalk7.default.dim("\u2500".repeat(60)));
2234
2348
  }
2235
2349
  function getSeverityColor(severity) {
2236
2350
  switch (severity.toLowerCase()) {
2237
2351
  case "critical":
2238
- return import_chalk6.default.red.bold;
2352
+ return import_chalk7.default.red.bold;
2239
2353
  case "high":
2240
- return import_chalk6.default.red;
2354
+ return import_chalk7.default.red;
2241
2355
  case "medium":
2242
- return import_chalk6.default.yellow;
2356
+ return import_chalk7.default.yellow;
2243
2357
  case "low":
2244
- return import_chalk6.default.blue;
2358
+ return import_chalk7.default.blue;
2245
2359
  case "info":
2246
- return import_chalk6.default.gray;
2360
+ return import_chalk7.default.gray;
2247
2361
  default:
2248
- return import_chalk6.default.white;
2362
+ return import_chalk7.default.white;
2249
2363
  }
2250
2364
  }
2251
2365
 
2252
2366
  // src/commands/fix.ts
2253
2367
  init_cjs_shims();
2254
2368
  var import_commander6 = require("commander");
2255
- var import_chalk7 = __toESM(require("chalk"), 1);
2369
+ var import_chalk8 = __toESM(require("chalk"), 1);
2256
2370
  var import_ora4 = __toESM(require("ora"), 1);
2257
2371
  var import_axios5 = __toESM(require("axios"), 1);
2258
2372
  var import_glob2 = require("glob");
2259
- var import_promises5 = __toESM(require("fs/promises"), 1);
2260
- var import_path5 = __toESM(require("path"), 1);
2373
+ var import_promises6 = __toESM(require("fs/promises"), 1);
2374
+ var import_path7 = __toESM(require("path"), 1);
2261
2375
  var import_inquirer = __toESM(require("inquirer"), 1);
2262
2376
  var Diff = __toESM(require("diff"), 1);
2263
2377
  init_config();
@@ -2269,31 +2383,31 @@ function createFixCommand() {
2269
2383
  const apiUrl = getApiUrl();
2270
2384
  const projectId = options.project || getProjectId();
2271
2385
  if (!projectId) {
2272
- 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>"));
2273
2387
  }
2274
- const scanPath = import_path5.default.resolve(process.cwd(), targetPath);
2388
+ const scanPath = import_path7.default.resolve(process.cwd(), targetPath);
2275
2389
  const gitignorePatterns = await readGitignore(scanPath);
2276
- const pattern = import_path5.default.join(scanPath, "**/*");
2390
+ const pattern = import_path7.default.join(scanPath, "**/*");
2277
2391
  const allFiles = await (0, import_glob2.glob)(pattern, { nodir: true, dot: false, ignore: ["**/node_modules/**", "**/.git/**"] });
2278
2392
  const codeFiles = allFiles.filter((file) => {
2279
- const relativePath = import_path5.default.relative(scanPath, file);
2393
+ const relativePath = import_path7.default.relative(scanPath, file);
2280
2394
  return isCodeFile(file) && !shouldIgnore(relativePath, gitignorePatterns);
2281
2395
  });
2282
2396
  if (codeFiles.length === 0) {
2283
- console.log(import_chalk7.default.yellow("No code files found."));
2397
+ console.log(import_chalk8.default.yellow("No code files found."));
2284
2398
  return;
2285
2399
  }
2286
- console.log(import_chalk7.default.bold(`
2400
+ console.log(import_chalk8.default.bold(`
2287
2401
  \u{1F9E0} Rigstate Fix Mode`));
2288
- 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...
2289
2403
  `));
2290
2404
  let fixedCount = 0;
2291
2405
  for (let i = 0; i < codeFiles.length; i++) {
2292
2406
  const filePath = codeFiles[i];
2293
- const relativePath = import_path5.default.relative(scanPath, filePath);
2407
+ const relativePath = import_path7.default.relative(scanPath, filePath);
2294
2408
  spinner.start(`Analyzing ${relativePath}...`);
2295
2409
  try {
2296
- const content = await import_promises5.default.readFile(filePath, "utf-8");
2410
+ const content = await import_promises6.default.readFile(filePath, "utf-8");
2297
2411
  const response = await import_axios5.default.post(
2298
2412
  `${apiUrl}/api/v1/audit`,
2299
2413
  { content, file_path: relativePath, project_id: projectId },
@@ -2304,22 +2418,22 @@ function createFixCommand() {
2304
2418
  if (fixableIssues.length > 0) {
2305
2419
  spinner.stop();
2306
2420
  console.log(`
2307
- ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2421
+ ${import_chalk8.default.bold(relativePath)}: Found ${fixableIssues.length} fixable issues.`);
2308
2422
  for (const issue of fixableIssues) {
2309
- console.log(import_chalk7.default.red(`
2423
+ console.log(import_chalk8.default.red(`
2310
2424
  [${issue.type}] ${issue.title}`));
2311
- console.log(import_chalk7.default.dim(issue.suggestion || issue.message));
2425
+ console.log(import_chalk8.default.dim(issue.suggestion || issue.message));
2312
2426
  const diff = Diff.createTwoFilesPatch(relativePath, relativePath, content, issue.fixed_content, "Current", "Fixed");
2313
2427
  console.log("\n" + diff.split("\n").slice(0, 15).join("\n") + (diff.split("\n").length > 15 ? "\n..." : ""));
2314
2428
  const { apply } = await import_inquirer.default.prompt([{
2315
2429
  type: "confirm",
2316
2430
  name: "apply",
2317
- message: `Apply this fix to ${import_chalk7.default.cyan(relativePath)}?`,
2431
+ message: `Apply this fix to ${import_chalk8.default.cyan(relativePath)}?`,
2318
2432
  default: true
2319
2433
  }]);
2320
2434
  if (apply) {
2321
- await import_promises5.default.writeFile(filePath, issue.fixed_content);
2322
- 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!`));
2323
2437
  fixedCount++;
2324
2438
  if (issue.related_step_id) {
2325
2439
  const { completeStep } = await import_inquirer.default.prompt([{
@@ -2335,15 +2449,15 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2335
2449
  { step_id: issue.related_step_id, status: "COMPLETED", project_id: projectId },
2336
2450
  { headers: { "Authorization": `Bearer ${apiKey}` } }
2337
2451
  );
2338
- 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.`));
2339
2453
  } catch (err) {
2340
- 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}`));
2341
2455
  }
2342
2456
  }
2343
2457
  }
2344
2458
  break;
2345
2459
  } else {
2346
- console.log(import_chalk7.default.dim("Skipped."));
2460
+ console.log(import_chalk8.default.dim("Skipped."));
2347
2461
  }
2348
2462
  }
2349
2463
  } else {
@@ -2353,11 +2467,11 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2353
2467
  }
2354
2468
  }
2355
2469
  spinner.stop();
2356
- console.log(import_chalk7.default.bold.green(`
2470
+ console.log(import_chalk8.default.bold.green(`
2357
2471
 
2358
2472
  \u{1F680} Fix session complete!`));
2359
2473
  console.log(`Frank fixed ${fixedCount} detected issues.`);
2360
- 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.`));
2361
2475
  } catch (error) {
2362
2476
  spinner.fail("Fix session failed");
2363
2477
  console.error(error.message);
@@ -2368,12 +2482,12 @@ ${import_chalk7.default.bold(relativePath)}: Found ${fixableIssues.length} fixab
2368
2482
  // src/commands/sync.ts
2369
2483
  init_cjs_shims();
2370
2484
  var import_commander7 = require("commander");
2371
- var import_chalk11 = __toESM(require("chalk"), 1);
2485
+ var import_chalk12 = __toESM(require("chalk"), 1);
2372
2486
  var import_ora5 = __toESM(require("ora"), 1);
2373
2487
  init_config();
2374
2488
  var import_axios8 = __toESM(require("axios"), 1);
2375
- var import_promises9 = __toESM(require("fs/promises"), 1);
2376
- var import_path9 = __toESM(require("path"), 1);
2489
+ var import_promises10 = __toESM(require("fs/promises"), 1);
2490
+ var import_path11 = __toESM(require("path"), 1);
2377
2491
  function createSyncCommand() {
2378
2492
  const sync = new import_commander7.Command("sync");
2379
2493
  sync.description("Synchronize local state with Rigstate Cloud").option("-p, --project <id>", "Specify Project ID (saves to config automatically)").action(async (options) => {
@@ -2388,13 +2502,9 @@ function createSyncCommand() {
2388
2502
  }
2389
2503
  let projectId = options.project;
2390
2504
  if (!projectId) {
2391
- try {
2392
- const manifestPath = import_path9.default.join(process.cwd(), ".rigstate");
2393
- const manifestContent = await import_promises9.default.readFile(manifestPath, "utf-8");
2394
- const manifest = JSON.parse(manifestContent);
2395
- if (manifest.project_id) projectId = manifest.project_id;
2396
- } catch (e) {
2397
- }
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;
2398
2508
  }
2399
2509
  if (!projectId) projectId = getProjectId();
2400
2510
  if (options.project) {
@@ -2414,31 +2524,30 @@ function createSyncCommand() {
2414
2524
  }
2415
2525
  const { roadmap, project } = response.data.data;
2416
2526
  const timestamp = response.data.timestamp;
2417
- const targetPath = import_path9.default.join(process.cwd(), "roadmap.json");
2527
+ const targetPath = import_path11.default.join(process.cwd(), "roadmap.json");
2418
2528
  const fileContent = JSON.stringify({
2419
2529
  project,
2420
2530
  last_synced: timestamp,
2421
2531
  roadmap
2422
2532
  }, null, 2);
2423
- await import_promises9.default.writeFile(targetPath, fileContent, "utf-8");
2533
+ await import_promises10.default.writeFile(targetPath, fileContent, "utf-8");
2424
2534
  try {
2425
- const manifestPath = import_path9.default.join(process.cwd(), ".rigstate");
2426
- const manifestContent = {
2535
+ const { saveManifest: saveManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
2536
+ await saveManifest2({
2427
2537
  project_id: projectId,
2428
- project_name: project,
2429
- last_synced: timestamp,
2538
+ linked_at: timestamp,
2539
+ // Using timestamp as linked_at for consistency
2430
2540
  api_url: apiUrl
2431
- };
2432
- await import_promises9.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2541
+ });
2433
2542
  } catch (e) {
2434
2543
  }
2435
- 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..."));
2436
2545
  try {
2437
2546
  const { provisionSkills: provisionSkills2, generateSkillsDiscoveryBlock: generateSkillsDiscoveryBlock2 } = await Promise.resolve().then(() => (init_skills_provisioner(), skills_provisioner_exports));
2438
2547
  const skills = await provisionSkills2(apiUrl, apiKey, projectId, process.cwd());
2439
- const cursorRulesPath = import_path9.default.join(process.cwd(), ".cursorrules");
2548
+ const cursorRulesPath = import_path11.default.join(process.cwd(), ".cursorrules");
2440
2549
  try {
2441
- let rulesContent = await import_promises9.default.readFile(cursorRulesPath, "utf-8");
2550
+ let rulesContent = await import_promises10.default.readFile(cursorRulesPath, "utf-8");
2442
2551
  const skillsBlock = generateSkillsDiscoveryBlock2(skills);
2443
2552
  if (rulesContent.includes("<available_skills>")) {
2444
2553
  rulesContent = rulesContent.replace(
@@ -2451,17 +2560,17 @@ function createSyncCommand() {
2451
2560
  rulesContent = rulesContent.slice(0, insertPoint + 3) + "\n\n" + skillsBlock + "\n" + rulesContent.slice(insertPoint + 3);
2452
2561
  }
2453
2562
  }
2454
- await import_promises9.default.writeFile(cursorRulesPath, rulesContent, "utf-8");
2455
- 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`));
2456
2565
  } catch (e) {
2457
2566
  }
2458
2567
  } catch (e) {
2459
- 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}`));
2460
2569
  }
2461
2570
  try {
2462
- 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");
2463
2572
  try {
2464
- const logContent = await import_promises9.default.readFile(logPath, "utf-8");
2573
+ const logContent = await import_promises10.default.readFile(logPath, "utf-8");
2465
2574
  const logData = JSON.parse(logContent);
2466
2575
  if (logData.task_summary) {
2467
2576
  await import_axios8.default.post(`${apiUrl}/api/v1/execution-logs`, {
@@ -2471,8 +2580,8 @@ function createSyncCommand() {
2471
2580
  }, {
2472
2581
  headers: { Authorization: `Bearer ${apiKey}` }
2473
2582
  });
2474
- await import_promises9.default.unlink(logPath);
2475
- 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.`));
2476
2585
  }
2477
2586
  } catch (e) {
2478
2587
  if (e.code !== "ENOENT") {
@@ -2480,12 +2589,12 @@ function createSyncCommand() {
2480
2589
  }
2481
2590
  } catch (e) {
2482
2591
  }
2483
- spinner.succeed(import_chalk11.default.green(`Synced ${roadmap.length} roadmap steps for project "${project}"`));
2484
- 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`));
2485
2594
  const { runGuardianWatchdog: runGuardianWatchdog2 } = await Promise.resolve().then(() => (init_watchdog(), watchdog_exports));
2486
2595
  const settings = response.data.data.settings || {};
2487
2596
  await runGuardianWatchdog2(process.cwd(), settings, projectId);
2488
- 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..."));
2489
2598
  try {
2490
2599
  const bridgeResponse = await import_axios8.default.get(`${apiUrl}/api/v1/agent/bridge`, {
2491
2600
  params: { project_id: projectId },
@@ -2496,10 +2605,10 @@ function createSyncCommand() {
2496
2605
  const pending = tasks.filter((t) => t.status === "PENDING");
2497
2606
  const approved = tasks.filter((t) => t.status === "APPROVED");
2498
2607
  if (pending.length > 0 || approved.length > 0) {
2499
- console.log(import_chalk11.default.yellow(`\u26A0 Bridge Alert: ${pending.length} pending, ${approved.length} approved tasks found.`));
2500
- 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.'));
2501
2610
  } else {
2502
- 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."));
2503
2612
  }
2504
2613
  const pings = pending.filter((t) => t.proposal?.startsWith("ping"));
2505
2614
  for (const ping of pings) {
@@ -2510,25 +2619,25 @@ function createSyncCommand() {
2510
2619
  }, {
2511
2620
  headers: { Authorization: `Bearer ${apiKey}` }
2512
2621
  });
2513
- 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}]`));
2514
2623
  }
2515
2624
  }
2516
2625
  } catch (e) {
2517
- 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}`));
2518
2627
  }
2519
2628
  if (options.project) {
2520
- 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.`));
2521
2630
  }
2522
2631
  try {
2523
- const migrationDir = import_path9.default.join(process.cwd(), "supabase", "migrations");
2524
- 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);
2525
2634
  const sqlFiles = files.filter((f) => f.endsWith(".sql")).sort();
2526
2635
  if (sqlFiles.length > 0) {
2527
2636
  const latestMigration = sqlFiles[sqlFiles.length - 1];
2528
- console.log(import_chalk11.default.dim(`
2637
+ console.log(import_chalk12.default.dim(`
2529
2638
  \u{1F6E1} Migration Guard:`));
2530
- console.log(import_chalk11.default.dim(` Latest Local: ${latestMigration}`));
2531
- 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.`));
2532
2641
  }
2533
2642
  } catch (e) {
2534
2643
  }
@@ -2540,15 +2649,15 @@ function createSyncCommand() {
2540
2649
  );
2541
2650
  if (vaultResponse.data.success) {
2542
2651
  const vaultContent = vaultResponse.data.data.content || "";
2543
- const localEnvPath = import_path9.default.join(process.cwd(), ".env.local");
2652
+ const localEnvPath = import_path11.default.join(process.cwd(), ".env.local");
2544
2653
  let localContent = "";
2545
2654
  try {
2546
- localContent = await import_promises9.default.readFile(localEnvPath, "utf-8");
2655
+ localContent = await import_promises10.default.readFile(localEnvPath, "utf-8");
2547
2656
  } catch (e) {
2548
2657
  }
2549
2658
  if (vaultContent.trim() !== localContent.trim()) {
2550
- console.log(import_chalk11.default.bold("\n\u{1F510} Sovereign Foundation (Vault):"));
2551
- 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"));
2552
2661
  const { syncVault } = await import("inquirer").then((m) => m.default.prompt([{
2553
2662
  type: "confirm",
2554
2663
  name: "syncVault",
@@ -2556,25 +2665,25 @@ function createSyncCommand() {
2556
2665
  default: false
2557
2666
  }]));
2558
2667
  if (syncVault) {
2559
- await import_promises9.default.writeFile(localEnvPath, vaultContent, "utf-8");
2560
- 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."));
2561
2670
  } else {
2562
- console.log(import_chalk11.default.dim(" Skipped vault sync."));
2671
+ console.log(import_chalk12.default.dim(" Skipped vault sync."));
2563
2672
  }
2564
2673
  } else {
2565
- 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."));
2566
2675
  }
2567
2676
  }
2568
2677
  } catch (e) {
2569
2678
  }
2570
- 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..."));
2571
2680
  await checkSystemIntegrity(apiUrl, apiKey, projectId);
2572
2681
  } catch (error) {
2573
2682
  if (import_axios8.default.isAxiosError(error)) {
2574
2683
  const message = error.response?.data?.error || error.message;
2575
- spinner.fail(import_chalk11.default.red(`Sync failed: ${message}`));
2684
+ spinner.fail(import_chalk12.default.red(`Sync failed: ${message}`));
2576
2685
  } else {
2577
- 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")));
2578
2687
  }
2579
2688
  }
2580
2689
  });
@@ -2590,64 +2699,49 @@ async function checkSystemIntegrity(apiUrl, apiKey, projectId) {
2590
2699
  const { migrations, rls, guardian_violations } = response.data.data;
2591
2700
  if (migrations) {
2592
2701
  if (migrations.in_sync) {
2593
- 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)`));
2594
2703
  } else {
2595
- 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.`));
2596
2705
  if (migrations.missing?.length > 0) {
2597
- 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 ? "..." : ""}`));
2598
2707
  }
2599
- 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.`));
2600
2709
  }
2601
2710
  }
2602
2711
  if (rls) {
2603
2712
  if (rls.all_secured) {
2604
- 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)`));
2605
2714
  } else {
2606
- 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.`));
2607
2716
  rls.unsecured?.forEach((table) => {
2608
- console.log(import_chalk11.default.red(` - ${table}`));
2717
+ console.log(import_chalk12.default.red(` - ${table}`));
2609
2718
  });
2610
- 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;'));
2611
2720
  }
2612
2721
  }
2613
2722
  if (guardian_violations) {
2614
2723
  if (guardian_violations.count === 0) {
2615
- console.log(import_chalk11.default.green(" \u2705 Guardian: No active violations"));
2724
+ console.log(import_chalk12.default.green(" \u2705 Guardian: No active violations"));
2616
2725
  } else {
2617
- console.log(import_chalk11.default.yellow(` \u26A0\uFE0F Guardian: ${guardian_violations.count} active violations`));
2618
- 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.'));
2619
2728
  }
2620
2729
  }
2621
2730
  }
2622
2731
  } catch (e) {
2623
- 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)"));
2624
2733
  }
2625
2734
  }
2626
2735
 
2627
2736
  // src/commands/init.ts
2628
2737
  init_cjs_shims();
2629
2738
  var import_commander8 = require("commander");
2630
- var import_chalk12 = __toESM(require("chalk"), 1);
2739
+ var import_chalk13 = __toESM(require("chalk"), 1);
2631
2740
  var import_promises11 = __toESM(require("fs/promises"), 1);
2632
- var import_path11 = __toESM(require("path"), 1);
2741
+ var import_path12 = __toESM(require("path"), 1);
2633
2742
  var import_ora6 = __toESM(require("ora"), 1);
2634
2743
  var import_child_process = require("child_process");
2635
-
2636
- // src/utils/manifest.ts
2637
- init_cjs_shims();
2638
- var import_promises10 = __toESM(require("fs/promises"), 1);
2639
- var import_path10 = __toESM(require("path"), 1);
2640
- async function loadManifest() {
2641
- try {
2642
- const manifestPath = import_path10.default.join(process.cwd(), ".rigstate");
2643
- const content = await import_promises10.default.readFile(manifestPath, "utf-8");
2644
- return JSON.parse(content);
2645
- } catch {
2646
- return null;
2647
- }
2648
- }
2649
-
2650
- // src/commands/init.ts
2744
+ init_manifest();
2651
2745
  init_config();
2652
2746
  var import_axios9 = __toESM(require("axios"), 1);
2653
2747
  function createInitCommand() {
@@ -2657,7 +2751,7 @@ function createInitCommand() {
2657
2751
  try {
2658
2752
  apiKey = getApiKey();
2659
2753
  } catch (e) {
2660
- 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.'));
2661
2755
  return;
2662
2756
  }
2663
2757
  const apiUrl = getApiUrl();
@@ -2754,7 +2848,7 @@ function createInitCommand() {
2754
2848
  selectedOrgId = orgId;
2755
2849
  }
2756
2850
  if (!selectedOrgId) {
2757
- 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."));
2758
2852
  return;
2759
2853
  }
2760
2854
  spinner.start("Creating new project...");
@@ -2766,13 +2860,13 @@ function createInitCommand() {
2766
2860
  headers: { Authorization: `Bearer ${apiKey}` }
2767
2861
  });
2768
2862
  if (!createResponse.data.success) {
2769
- 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));
2770
2864
  return;
2771
2865
  }
2772
2866
  projectId = createResponse.data.data.project.id;
2773
- spinner.succeed(import_chalk12.default.green(`Created new project: ${newName}`));
2867
+ spinner.succeed(import_chalk13.default.green(`Created new project: ${newName}`));
2774
2868
  } catch (e) {
2775
- 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."));
2776
2870
  return;
2777
2871
  }
2778
2872
  } else {
@@ -2782,28 +2876,27 @@ function createInitCommand() {
2782
2876
  spinner.start(`Linking to project ID: ${projectId}...`);
2783
2877
  }
2784
2878
  setProjectId(projectId);
2785
- const manifestPath = import_path11.default.join(process.cwd(), ".rigstate");
2786
- const manifestContent = {
2879
+ const { saveManifest: saveManifest2 } = await Promise.resolve().then(() => (init_manifest(), manifest_exports));
2880
+ await saveManifest2({
2787
2881
  project_id: projectId,
2788
- last_linked: (/* @__PURE__ */ new Date()).toISOString(),
2882
+ linked_at: (/* @__PURE__ */ new Date()).toISOString(),
2789
2883
  api_url: apiUrl
2790
- };
2791
- await import_promises11.default.writeFile(manifestPath, JSON.stringify(manifestContent, null, 2), "utf-8");
2884
+ });
2792
2885
  try {
2793
2886
  await import_promises11.default.access(".git");
2794
2887
  } catch {
2795
2888
  spinner.text = "Initializing git repository...";
2796
2889
  (0, import_child_process.execSync)("git init", { stdio: "ignore" });
2797
2890
  }
2798
- spinner.succeed(import_chalk12.default.green(`\u2705 Linked to project: ${projectId}`));
2891
+ spinner.succeed(import_chalk13.default.green(`\u2705 Linked to project: ${projectId}`));
2799
2892
  await generateRules(apiUrl, apiKey, projectId, options.force, spinner);
2800
2893
  console.log("");
2801
- console.log(import_chalk12.default.blue("Next steps:"));
2802
- console.log(import_chalk12.default.dim(" rigstate sync - Sync roadmap and context"));
2803
- console.log(import_chalk12.default.dim(" rigstate watch - Start development loop"));
2804
- 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"));
2805
2898
  } catch (e) {
2806
- spinner.fail(import_chalk12.default.red("Initialization failed: " + e.message));
2899
+ spinner.fail(import_chalk13.default.red("Initialization failed: " + e.message));
2807
2900
  }
2808
2901
  });
2809
2902
  }
@@ -2818,19 +2911,19 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
2818
2911
  if (response.data.success || response.data.files) {
2819
2912
  const files = response.data.files || [];
2820
2913
  if (files.length === 0 && response.data.rules) {
2821
- const rulesPath = import_path11.default.join(process.cwd(), ".cursorrules");
2914
+ const rulesPath = import_path12.default.join(process.cwd(), ".cursorrules");
2822
2915
  await import_promises11.default.writeFile(rulesPath, response.data.rules, "utf-8");
2823
- spinner.succeed(import_chalk12.default.green("\u2714 Generated .cursorrules (legacy mode)"));
2916
+ spinner.succeed(import_chalk13.default.green("\u2714 Generated .cursorrules (legacy mode)"));
2824
2917
  return;
2825
2918
  }
2826
2919
  for (const file of files) {
2827
- const targetPath = import_path11.default.join(process.cwd(), file.path);
2828
- 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);
2829
2922
  await import_promises11.default.mkdir(targetDir, { recursive: true });
2830
2923
  try {
2831
2924
  await import_promises11.default.access(targetPath);
2832
2925
  if (!force && !file.path.startsWith(".cursor/rules/")) {
2833
- console.log(import_chalk12.default.dim(` ${file.path} already exists. Skipping.`));
2926
+ console.log(import_chalk13.default.dim(` ${file.path} already exists. Skipping.`));
2834
2927
  continue;
2835
2928
  }
2836
2929
  } catch {
@@ -2838,45 +2931,46 @@ async function generateRules(apiUrl, apiKey, projectId, force, spinner) {
2838
2931
  await import_promises11.default.writeFile(targetPath, file.content, "utf-8");
2839
2932
  }
2840
2933
  if (files.length > 0) {
2841
- const legacyPath = import_path11.default.join(process.cwd(), ".cursorrules");
2934
+ const legacyPath = import_path12.default.join(process.cwd(), ".cursorrules");
2842
2935
  try {
2843
2936
  const stats = await import_promises11.default.stat(legacyPath);
2844
2937
  if (stats.isFile()) {
2845
2938
  await import_promises11.default.rename(legacyPath, `${legacyPath}.bak`);
2846
- 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"));
2847
2940
  }
2848
2941
  } catch (e) {
2849
2942
  }
2850
2943
  }
2851
- 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"})`));
2852
2945
  } else {
2853
- 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)"));
2854
2947
  }
2855
2948
  } catch (e) {
2856
- spinner.info(import_chalk12.default.dim(` Rules generation failed: ${e.message}`));
2949
+ spinner.info(import_chalk13.default.dim(` Rules generation failed: ${e.message}`));
2857
2950
  }
2858
2951
  }
2859
2952
 
2860
2953
  // src/commands/check.ts
2861
2954
  init_cjs_shims();
2862
2955
  var import_commander9 = require("commander");
2863
- var import_chalk14 = __toESM(require("chalk"), 1);
2956
+ var import_chalk15 = __toESM(require("chalk"), 1);
2864
2957
  var import_ora7 = __toESM(require("ora"), 1);
2865
2958
  var import_axios10 = __toESM(require("axios"), 1);
2866
2959
  var import_glob3 = require("glob");
2867
2960
  var import_promises13 = __toESM(require("fs/promises"), 1);
2868
- var import_path13 = __toESM(require("path"), 1);
2961
+ var import_path14 = __toESM(require("path"), 1);
2869
2962
  var import_child_process2 = require("child_process");
2870
2963
  init_config();
2964
+ init_manifest();
2871
2965
 
2872
2966
  // src/utils/rule-engine.ts
2873
2967
  init_cjs_shims();
2874
2968
  var import_promises12 = __toESM(require("fs/promises"), 1);
2875
- var import_path12 = __toESM(require("path"), 1);
2876
- var import_chalk13 = __toESM(require("chalk"), 1);
2969
+ var import_path13 = __toESM(require("path"), 1);
2970
+ var import_chalk14 = __toESM(require("chalk"), 1);
2877
2971
  async function checkFile(filePath, rules, rootPath) {
2878
2972
  const violations = [];
2879
- const relativePath = import_path12.default.relative(rootPath, filePath);
2973
+ const relativePath = import_path13.default.relative(rootPath, filePath);
2880
2974
  try {
2881
2975
  const content = await import_promises12.default.readFile(filePath, "utf-8");
2882
2976
  const lines = content.split("\n");
@@ -2969,7 +3063,7 @@ async function evaluateRule(rule, content, lines, filePath) {
2969
3063
  case "NAMING_CONVENTION": {
2970
3064
  const value = rule.value;
2971
3065
  const pattern = new RegExp(value.pattern);
2972
- const fileName = import_path12.default.basename(filePath);
3066
+ const fileName = import_path13.default.basename(filePath);
2973
3067
  if (filePath.includes(value.context) && !pattern.test(fileName)) {
2974
3068
  violations.push({
2975
3069
  file: filePath,
@@ -3028,12 +3122,12 @@ function checkFunctionLines(content, lines, filePath, rule, limit) {
3028
3122
  }
3029
3123
  function formatViolations(violations) {
3030
3124
  for (const v of violations) {
3031
- const severityColor = v.severity === "critical" ? import_chalk13.default.red : v.severity === "warning" ? import_chalk13.default.yellow : import_chalk13.default.blue;
3032
- 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}`) : "";
3033
3127
  console.log(` ${severityColor(`[${v.severity.toUpperCase()}]`)} ${v.file}${lineInfo}`);
3034
3128
  console.log(` ${v.message}`);
3035
3129
  if (v.details) {
3036
- console.log(` ${import_chalk13.default.dim(v.details)}`);
3130
+ console.log(` ${import_chalk14.default.dim(v.details)}`);
3037
3131
  }
3038
3132
  }
3039
3133
  }
@@ -3078,15 +3172,15 @@ function createCheckCommand() {
3078
3172
  projectId = getProjectId();
3079
3173
  }
3080
3174
  if (!projectId) {
3081
- console.log(import_chalk14.default.red("\u274C No project context found."));
3082
- 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>'));
3083
3177
  process.exit(2);
3084
3178
  }
3085
3179
  let apiKey;
3086
3180
  try {
3087
3181
  apiKey = getApiKey();
3088
3182
  } catch {
3089
- 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.'));
3090
3184
  process.exit(2);
3091
3185
  }
3092
3186
  spinner.start("Fetching Guardian rules...");
@@ -3114,17 +3208,17 @@ function createCheckCommand() {
3114
3208
  } catch (apiError) {
3115
3209
  const cached = await loadCachedRules(projectId);
3116
3210
  if (cached && !isStale(cached.timestamp, CACHE_MAX_AGE_MS)) {
3117
- spinner.warn(import_chalk14.default.yellow("Using cached rules (API unavailable)"));
3211
+ spinner.warn(import_chalk15.default.yellow("Using cached rules (API unavailable)"));
3118
3212
  rules = cached.rules;
3119
3213
  settings = cached.settings;
3120
3214
  } else {
3121
- spinner.fail(import_chalk14.default.red("Failed to fetch rules and no valid cache"));
3122
- 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}`));
3123
3217
  process.exit(2);
3124
3218
  }
3125
3219
  }
3126
3220
  spinner.succeed(`Loaded ${rules.length} Guardian rules`);
3127
- const scanPath = import_path13.default.resolve(process.cwd(), targetPath);
3221
+ const scanPath = import_path14.default.resolve(process.cwd(), targetPath);
3128
3222
  let filesToCheck;
3129
3223
  if (options.staged) {
3130
3224
  spinner.start("Getting staged files...");
@@ -3133,14 +3227,14 @@ function createCheckCommand() {
3133
3227
  encoding: "utf-8",
3134
3228
  cwd: process.cwd()
3135
3229
  });
3136
- 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));
3137
3231
  } catch {
3138
3232
  spinner.fail("Not a git repository or no staged files");
3139
3233
  process.exit(2);
3140
3234
  }
3141
3235
  } else {
3142
- spinner.start(`Scanning ${import_chalk14.default.cyan(targetPath)}...`);
3143
- const pattern = import_path13.default.join(scanPath, "**/*");
3236
+ spinner.start(`Scanning ${import_chalk15.default.cyan(targetPath)}...`);
3237
+ const pattern = import_path14.default.join(scanPath, "**/*");
3144
3238
  const allFiles = await (0, import_glob3.glob)(pattern, {
3145
3239
  nodir: true,
3146
3240
  dot: false,
@@ -3156,7 +3250,7 @@ function createCheckCommand() {
3156
3250
  filesToCheck = allFiles.filter((f) => isCodeFile2(f));
3157
3251
  }
3158
3252
  if (filesToCheck.length === 0) {
3159
- 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."));
3160
3254
  outputResults([], !!options.json);
3161
3255
  process.exit(0);
3162
3256
  }
@@ -3165,7 +3259,7 @@ function createCheckCommand() {
3165
3259
  const results = [];
3166
3260
  for (let i = 0; i < filesToCheck.length; i++) {
3167
3261
  const file = filesToCheck[i];
3168
- 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)}`;
3169
3263
  const result = await checkFile(file, rules, process.cwd());
3170
3264
  results.push(result);
3171
3265
  }
@@ -3175,46 +3269,46 @@ function createCheckCommand() {
3175
3269
  outputResults(results, true);
3176
3270
  } else {
3177
3271
  outputResults(results, false);
3178
- console.log("\n" + import_chalk14.default.bold("\u{1F4CA} Summary"));
3179
- console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3180
- console.log(`Files checked: ${import_chalk14.default.cyan(summary.totalFiles)}`);
3181
- 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)}`);
3182
3276
  if (summary.totalViolations > 0) {
3183
- console.log(` ${import_chalk14.default.red("Critical:")} ${summary.criticalCount}`);
3184
- console.log(` ${import_chalk14.default.yellow("Warning:")} ${summary.warningCount}`);
3185
- 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}`);
3186
3280
  }
3187
- console.log(import_chalk14.default.dim("\u2500".repeat(50)));
3281
+ console.log(import_chalk15.default.dim("\u2500".repeat(50)));
3188
3282
  }
3189
3283
  if (options.strict !== void 0) {
3190
3284
  const strictLevel = typeof options.strict === "string" ? options.strict : "all";
3191
3285
  if (strictLevel === "critical" && summary.criticalCount > 0) {
3192
- 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"));
3193
3287
  process.exit(1);
3194
3288
  } else if (strictLevel === "all" && summary.totalViolations > 0) {
3195
- 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"));
3196
3290
  process.exit(1);
3197
3291
  }
3198
3292
  }
3199
3293
  if (summary.totalViolations === 0) {
3200
- console.log(import_chalk14.default.green("\n\u2705 All checks passed!"));
3294
+ console.log(import_chalk15.default.green("\n\u2705 All checks passed!"));
3201
3295
  }
3202
3296
  process.exit(0);
3203
3297
  } catch (error) {
3204
- spinner.fail(import_chalk14.default.red("Check failed"));
3205
- 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);
3206
3300
  process.exit(2);
3207
3301
  }
3208
3302
  });
3209
3303
  }
3210
3304
  function isCodeFile2(filePath) {
3211
3305
  const codeExtensions = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3212
- const ext = import_path13.default.extname(filePath).toLowerCase();
3306
+ const ext = import_path14.default.extname(filePath).toLowerCase();
3213
3307
  return codeExtensions.includes(ext);
3214
3308
  }
3215
3309
  async function loadCachedRules(projectId) {
3216
3310
  try {
3217
- const cachePath = import_path13.default.join(process.cwd(), CACHE_FILE2);
3311
+ const cachePath = import_path14.default.join(process.cwd(), CACHE_FILE2);
3218
3312
  const content = await import_promises13.default.readFile(cachePath, "utf-8");
3219
3313
  const cached = JSON.parse(content);
3220
3314
  if (cached.projectId !== projectId) {
@@ -3227,7 +3321,7 @@ async function loadCachedRules(projectId) {
3227
3321
  }
3228
3322
  async function saveCachedRules(projectId, rules, settings) {
3229
3323
  try {
3230
- const cacheDir = import_path13.default.join(process.cwd(), ".rigstate");
3324
+ const cacheDir = import_path14.default.join(process.cwd(), ".rigstate");
3231
3325
  await import_promises13.default.mkdir(cacheDir, { recursive: true });
3232
3326
  const cached = {
3233
3327
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3236,7 +3330,7 @@ async function saveCachedRules(projectId, rules, settings) {
3236
3330
  settings
3237
3331
  };
3238
3332
  await import_promises13.default.writeFile(
3239
- import_path13.default.join(cacheDir, "rules-cache.json"),
3333
+ import_path14.default.join(cacheDir, "rules-cache.json"),
3240
3334
  JSON.stringify(cached, null, 2)
3241
3335
  );
3242
3336
  } catch {
@@ -3258,8 +3352,8 @@ function outputResults(results, json) {
3258
3352
  if (!hasViolations) {
3259
3353
  return;
3260
3354
  }
3261
- console.log("\n" + import_chalk14.default.bold("\u{1F50D} Violations Found"));
3262
- 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)));
3263
3357
  for (const result of results) {
3264
3358
  if (result.violations.length > 0) {
3265
3359
  formatViolations(result.violations);
@@ -3270,9 +3364,9 @@ function outputResults(results, json) {
3270
3364
  // src/commands/hooks.ts
3271
3365
  init_cjs_shims();
3272
3366
  var import_commander10 = require("commander");
3273
- var import_chalk15 = __toESM(require("chalk"), 1);
3367
+ var import_chalk16 = __toESM(require("chalk"), 1);
3274
3368
  var import_promises14 = __toESM(require("fs/promises"), 1);
3275
- var import_path14 = __toESM(require("path"), 1);
3369
+ var import_path15 = __toESM(require("path"), 1);
3276
3370
  var PRE_COMMIT_SCRIPT = `#!/bin/sh
3277
3371
  # Rigstate Guardian Pre-commit Hook
3278
3372
  # Installed by: rigstate hooks install
@@ -3301,23 +3395,23 @@ function createHooksCommand() {
3301
3395
  const hooks = new import_commander10.Command("hooks").description("Manage git hooks for Guardian integration");
3302
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) => {
3303
3397
  try {
3304
- const gitDir = import_path14.default.join(process.cwd(), ".git");
3398
+ const gitDir = import_path15.default.join(process.cwd(), ".git");
3305
3399
  try {
3306
3400
  await import_promises14.default.access(gitDir);
3307
3401
  } catch {
3308
- console.log(import_chalk15.default.red("\u274C Not a git repository."));
3309
- 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.'));
3310
3404
  process.exit(1);
3311
3405
  }
3312
- const hooksDir = import_path14.default.join(gitDir, "hooks");
3406
+ const hooksDir = import_path15.default.join(gitDir, "hooks");
3313
3407
  await import_promises14.default.mkdir(hooksDir, { recursive: true });
3314
- const preCommitPath = import_path14.default.join(hooksDir, "pre-commit");
3408
+ const preCommitPath = import_path15.default.join(hooksDir, "pre-commit");
3315
3409
  let existingContent = "";
3316
3410
  try {
3317
3411
  existingContent = await import_promises14.default.readFile(preCommitPath, "utf-8");
3318
3412
  if (existingContent.includes("rigstate")) {
3319
- console.log(import_chalk15.default.yellow("\u26A0 Rigstate pre-commit hook already installed."));
3320
- 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.'));
3321
3415
  return;
3322
3416
  }
3323
3417
  } catch {
@@ -3329,33 +3423,33 @@ function createHooksCommand() {
3329
3423
  if (existingContent && !existingContent.includes("rigstate")) {
3330
3424
  const combinedScript = existingContent + "\n\n" + script.replace("#!/bin/sh\n", "");
3331
3425
  await import_promises14.default.writeFile(preCommitPath, combinedScript, { mode: 493 });
3332
- 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."));
3333
3427
  } else {
3334
3428
  await import_promises14.default.writeFile(preCommitPath, script, { mode: 493 });
3335
- console.log(import_chalk15.default.green("\u2705 Pre-commit hook installed!"));
3429
+ console.log(import_chalk16.default.green("\u2705 Pre-commit hook installed!"));
3336
3430
  }
3337
- console.log(import_chalk15.default.dim(` Path: ${preCommitPath}`));
3338
- 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}`));
3339
3433
  console.log("");
3340
- console.log(import_chalk15.default.cyan("Guardian will now check your code before each commit."));
3341
- 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.'));
3342
3436
  } catch (error) {
3343
- 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);
3344
3438
  process.exit(1);
3345
3439
  }
3346
3440
  });
3347
3441
  hooks.command("uninstall").description("Remove Rigstate pre-commit hook").action(async () => {
3348
3442
  try {
3349
- 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");
3350
3444
  try {
3351
3445
  const content = await import_promises14.default.readFile(preCommitPath, "utf-8");
3352
3446
  if (!content.includes("rigstate")) {
3353
- 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."));
3354
3448
  return;
3355
3449
  }
3356
3450
  if (content.includes("# Rigstate Guardian Pre-commit Hook") && content.trim().split("\n").filter((l) => l && !l.startsWith("#")).length <= 4) {
3357
3451
  await import_promises14.default.unlink(preCommitPath);
3358
- console.log(import_chalk15.default.green("\u2705 Pre-commit hook removed."));
3452
+ console.log(import_chalk16.default.green("\u2705 Pre-commit hook removed."));
3359
3453
  } else {
3360
3454
  const lines = content.split("\n");
3361
3455
  const filteredLines = [];
@@ -3374,13 +3468,13 @@ function createHooksCommand() {
3374
3468
  }
3375
3469
  }
3376
3470
  await import_promises14.default.writeFile(preCommitPath, filteredLines.join("\n"), { mode: 493 });
3377
- 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."));
3378
3472
  }
3379
3473
  } catch {
3380
- 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."));
3381
3475
  }
3382
3476
  } catch (error) {
3383
- 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);
3384
3478
  process.exit(1);
3385
3479
  }
3386
3480
  });
@@ -3390,40 +3484,40 @@ function createHooksCommand() {
3390
3484
  // src/commands/daemon.ts
3391
3485
  init_cjs_shims();
3392
3486
  var import_commander11 = require("commander");
3393
- var import_chalk21 = __toESM(require("chalk"), 1);
3487
+ var import_chalk22 = __toESM(require("chalk"), 1);
3394
3488
  var import_ora8 = __toESM(require("ora"), 1);
3395
3489
  var import_promises19 = __toESM(require("fs/promises"), 1);
3396
- var import_path22 = __toESM(require("path"), 1);
3490
+ var import_path23 = __toESM(require("path"), 1);
3397
3491
 
3398
3492
  // src/daemon/factory.ts
3399
3493
  init_cjs_shims();
3400
3494
 
3401
3495
  // src/daemon/core.ts
3402
3496
  init_cjs_shims();
3403
- var import_chalk19 = __toESM(require("chalk"), 1);
3404
- var fs18 = __toESM(require("fs/promises"), 1);
3405
- 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);
3406
3500
  var import_events4 = require("events");
3407
3501
 
3408
3502
  // src/daemon/file-watcher.ts
3409
3503
  init_cjs_shims();
3410
3504
  var chokidar = __toESM(require("chokidar"), 1);
3411
- var import_path15 = __toESM(require("path"), 1);
3505
+ var import_path16 = __toESM(require("path"), 1);
3412
3506
  var import_events = require("events");
3413
3507
  var CODE_EXTENSIONS = [".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs"];
3414
3508
  function isCodeFile3(filePath) {
3415
- const ext = import_path15.default.extname(filePath).toLowerCase();
3509
+ const ext = import_path16.default.extname(filePath).toLowerCase();
3416
3510
  return CODE_EXTENSIONS.includes(ext);
3417
3511
  }
3418
3512
  function createFileWatcher(watchPath) {
3419
3513
  const emitter = new import_events.EventEmitter();
3420
3514
  let watcher = null;
3421
3515
  emitter.start = () => {
3422
- const absolutePath = import_path15.default.resolve(process.cwd(), watchPath);
3516
+ const absolutePath = import_path16.default.resolve(process.cwd(), watchPath);
3423
3517
  watcher = chokidar.watch(absolutePath, {
3424
3518
  ignored: (pathStr) => {
3425
- const relativePath = import_path15.default.relative(process.cwd(), pathStr);
3426
- 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);
3427
3521
  const ignoreDirs = [
3428
3522
  "node_modules",
3429
3523
  ".git",
@@ -3455,7 +3549,7 @@ function createFileWatcher(watchPath) {
3455
3549
  if (segments.some((segment) => ignoreDirs.includes(segment))) {
3456
3550
  return true;
3457
3551
  }
3458
- const isFile = !!import_path15.default.extname(pathStr);
3552
+ const isFile = !!import_path16.default.extname(pathStr);
3459
3553
  if (isFile && !isCodeFile3(pathStr)) {
3460
3554
  return true;
3461
3555
  }
@@ -3478,17 +3572,17 @@ function createFileWatcher(watchPath) {
3478
3572
  });
3479
3573
  watcher.on("change", (filePath) => {
3480
3574
  if (isCodeFile3(filePath)) {
3481
- emitter.emit("change", import_path15.default.relative(process.cwd(), filePath));
3575
+ emitter.emit("change", import_path16.default.relative(process.cwd(), filePath));
3482
3576
  }
3483
3577
  });
3484
3578
  watcher.on("add", (filePath) => {
3485
3579
  if (isCodeFile3(filePath)) {
3486
- emitter.emit("add", import_path15.default.relative(process.cwd(), filePath));
3580
+ emitter.emit("add", import_path16.default.relative(process.cwd(), filePath));
3487
3581
  }
3488
3582
  });
3489
3583
  watcher.on("unlink", (filePath) => {
3490
3584
  if (isCodeFile3(filePath)) {
3491
- emitter.emit("unlink", import_path15.default.relative(process.cwd(), filePath));
3585
+ emitter.emit("unlink", import_path16.default.relative(process.cwd(), filePath));
3492
3586
  }
3493
3587
  });
3494
3588
  watcher.on("error", (error) => {
@@ -3510,8 +3604,8 @@ function createFileWatcher(watchPath) {
3510
3604
  // src/daemon/heuristic-engine.ts
3511
3605
  init_cjs_shims();
3512
3606
  var import_promises15 = require("fs/promises");
3513
- var import_path16 = require("path");
3514
- var import_path17 = __toESM(require("path"), 1);
3607
+ var import_path17 = require("path");
3608
+ var import_path18 = __toESM(require("path"), 1);
3515
3609
  var import_axios11 = __toESM(require("axios"), 1);
3516
3610
  var GLOBAL_HEURISTICS = [
3517
3611
  {
@@ -3543,7 +3637,7 @@ var HeuristicEngine = class {
3543
3637
  rules = [];
3544
3638
  cachePath;
3545
3639
  constructor() {
3546
- 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");
3547
3641
  this.loadRules();
3548
3642
  }
3549
3643
  async loadRules() {
@@ -3560,7 +3654,7 @@ var HeuristicEngine = class {
3560
3654
  }
3561
3655
  async refreshRules(projectId, apiUrl, apiKey) {
3562
3656
  try {
3563
- 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 });
3564
3658
  const endpoint = `${apiUrl}/api/v1/skills/triggers`;
3565
3659
  const response = await import_axios11.default.get(endpoint, {
3566
3660
  headers: {
@@ -3658,9 +3752,9 @@ function createHeuristicEngine() {
3658
3752
 
3659
3753
  // src/daemon/intervention-protocol.ts
3660
3754
  init_cjs_shims();
3661
- var import_chalk16 = __toESM(require("chalk"), 1);
3662
- var fs15 = __toESM(require("fs"), 1);
3663
- 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);
3664
3758
  var InterventionProtocol = class {
3665
3759
  activeViolators = /* @__PURE__ */ new Set();
3666
3760
  /**
@@ -3683,18 +3777,18 @@ var InterventionProtocol = class {
3683
3777
  }
3684
3778
  syncLockFile() {
3685
3779
  try {
3686
- const lockDir = path17.join(process.cwd(), ".rigstate");
3687
- if (!fs15.existsSync(lockDir)) fs15.mkdirSync(lockDir, { recursive: true });
3688
- 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");
3689
3783
  if (this.activeViolators.size > 0) {
3690
3784
  const content = `HARD_LOCK_ACTIVE
3691
3785
  Timestamp: ${(/* @__PURE__ */ new Date()).toISOString()}
3692
3786
 
3693
3787
  Blocking Files:
3694
3788
  ${Array.from(this.activeViolators).join("\n")}`;
3695
- fs15.writeFileSync(lockPath, content, "utf-8");
3789
+ fs16.writeFileSync(lockPath, content, "utf-8");
3696
3790
  } else {
3697
- if (fs15.existsSync(lockPath)) fs15.unlinkSync(lockPath);
3791
+ if (fs16.existsSync(lockPath)) fs16.unlinkSync(lockPath);
3698
3792
  }
3699
3793
  } catch (e) {
3700
3794
  console.error("Failed to sync guardian lock file:", e);
@@ -3748,11 +3842,11 @@ ${Array.from(this.activeViolators).join("\n")}`;
3748
3842
  enforce(decision) {
3749
3843
  if (decision.mode === "OPEN") return;
3750
3844
  const icon = decision.mode === "HARD_LOCK" ? "\u{1F6AB}" : "\u26A0\uFE0F";
3751
- 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;
3752
3846
  console.log("\n" + color(` ${icon} [${decision.mode}] INTERVENTION `));
3753
- console.log(import_chalk16.default.redBright(` ${decision.message}`));
3847
+ console.log(import_chalk17.default.redBright(` ${decision.message}`));
3754
3848
  if (decision.blockCommit) {
3755
- 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."));
3756
3850
  }
3757
3851
  }
3758
3852
  };
@@ -3763,9 +3857,9 @@ function createInterventionProtocol() {
3763
3857
  // src/daemon/guardian-monitor.ts
3764
3858
  init_cjs_shims();
3765
3859
  var import_axios12 = __toESM(require("axios"), 1);
3766
- var import_chalk17 = __toESM(require("chalk"), 1);
3860
+ var import_chalk18 = __toESM(require("chalk"), 1);
3767
3861
  var import_promises16 = __toESM(require("fs/promises"), 1);
3768
- var import_path18 = __toESM(require("path"), 1);
3862
+ var import_path19 = __toESM(require("path"), 1);
3769
3863
  var CACHE_FILE3 = ".rigstate/rules-cache.json";
3770
3864
  var CACHE_TTL_MS2 = 5 * 60 * 1e3;
3771
3865
  function createGuardianMonitor(projectId, apiUrl, apiKey) {
@@ -3790,7 +3884,7 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3790
3884
  } catch (error) {
3791
3885
  if (apiUrl.includes("localhost") || apiUrl.includes("127.0.0.1")) {
3792
3886
  const cloudUrl = "https://app.rigstate.com";
3793
- 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})...`));
3794
3888
  try {
3795
3889
  const cloudResponse = await import_axios12.default.get(`${cloudUrl}/api/v1/guardian/rules`, {
3796
3890
  params: { project_id: projectId },
@@ -3799,22 +3893,22 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3799
3893
  });
3800
3894
  if (cloudResponse.data.success && cloudResponse.data.data.rules) {
3801
3895
  rules = cloudResponse.data.data.rules;
3802
- 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!`));
3803
3897
  lastFetch = Date.now();
3804
3898
  await saveCachedRules2(projectId, rules);
3805
3899
  return;
3806
3900
  }
3807
3901
  } catch (cloudError) {
3808
- 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}`));
3809
3903
  }
3810
3904
  }
3811
- 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}`));
3812
3906
  if (error.response) {
3813
- 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)}`));
3814
3908
  }
3815
3909
  const cached = await loadCachedRules2(projectId);
3816
3910
  if (cached) {
3817
- 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"));
3818
3912
  rules = cached.rules;
3819
3913
  lastFetch = Date.now();
3820
3914
  return;
@@ -3831,7 +3925,7 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3831
3925
  passed: true
3832
3926
  };
3833
3927
  }
3834
- const absolutePath = import_path18.default.resolve(process.cwd(), filePath);
3928
+ const absolutePath = import_path19.default.resolve(process.cwd(), filePath);
3835
3929
  return checkFile(absolutePath, rules, process.cwd());
3836
3930
  };
3837
3931
  const getRuleCount = () => rules.length;
@@ -3845,7 +3939,7 @@ function createGuardianMonitor(projectId, apiUrl, apiKey) {
3845
3939
  }
3846
3940
  async function loadCachedRules2(projectId) {
3847
3941
  try {
3848
- const cachePath = import_path18.default.join(process.cwd(), CACHE_FILE3);
3942
+ const cachePath = import_path19.default.join(process.cwd(), CACHE_FILE3);
3849
3943
  const content = await import_promises16.default.readFile(cachePath, "utf-8");
3850
3944
  const cached = JSON.parse(content);
3851
3945
  if (cached.projectId !== projectId) {
@@ -3858,7 +3952,7 @@ async function loadCachedRules2(projectId) {
3858
3952
  }
3859
3953
  async function saveCachedRules2(projectId, rules) {
3860
3954
  try {
3861
- const cacheDir = import_path18.default.join(process.cwd(), ".rigstate");
3955
+ const cacheDir = import_path19.default.join(process.cwd(), ".rigstate");
3862
3956
  await import_promises16.default.mkdir(cacheDir, { recursive: true });
3863
3957
  const cached = {
3864
3958
  timestamp: (/* @__PURE__ */ new Date()).toISOString(),
@@ -3867,7 +3961,7 @@ async function saveCachedRules2(projectId, rules) {
3867
3961
  settings: { lmax: 400, lmax_warning: 350 }
3868
3962
  };
3869
3963
  await import_promises16.default.writeFile(
3870
- import_path18.default.join(cacheDir, "rules-cache.json"),
3964
+ import_path19.default.join(cacheDir, "rules-cache.json"),
3871
3965
  JSON.stringify(cached, null, 2)
3872
3966
  );
3873
3967
  } catch {
@@ -3967,37 +4061,37 @@ init_sync_rules();
3967
4061
 
3968
4062
  // src/utils/logger.ts
3969
4063
  init_cjs_shims();
3970
- var import_chalk18 = __toESM(require("chalk"), 1);
4064
+ var import_chalk19 = __toESM(require("chalk"), 1);
3971
4065
  var Logger = class {
3972
4066
  static formatMessage(level, message, context) {
3973
4067
  const timestamp = (/* @__PURE__ */ new Date()).toISOString();
3974
4068
  let prefix = "";
3975
4069
  switch (level) {
3976
4070
  case "INFO" /* INFO */:
3977
- prefix = import_chalk18.default.blue(`[${"INFO" /* INFO */}]`);
4071
+ prefix = import_chalk19.default.blue(`[${"INFO" /* INFO */}]`);
3978
4072
  break;
3979
4073
  case "WARN" /* WARN */:
3980
- prefix = import_chalk18.default.yellow(`[${"WARN" /* WARN */}]`);
4074
+ prefix = import_chalk19.default.yellow(`[${"WARN" /* WARN */}]`);
3981
4075
  break;
3982
4076
  case "ERROR" /* ERROR */:
3983
- prefix = import_chalk18.default.red(`[${"ERROR" /* ERROR */}]`);
4077
+ prefix = import_chalk19.default.red(`[${"ERROR" /* ERROR */}]`);
3984
4078
  break;
3985
4079
  case "DEBUG" /* DEBUG */:
3986
- prefix = import_chalk18.default.gray(`[${"DEBUG" /* DEBUG */}]`);
4080
+ prefix = import_chalk19.default.gray(`[${"DEBUG" /* DEBUG */}]`);
3987
4081
  break;
3988
4082
  }
3989
- let output = `${import_chalk18.default.gray(timestamp)} ${prefix} ${message}`;
4083
+ let output = `${import_chalk19.default.gray(timestamp)} ${prefix} ${message}`;
3990
4084
  if (context) {
3991
4085
  if (context instanceof Error) {
3992
4086
  output += `
3993
- ${import_chalk18.default.red(context.stack || context.message)}`;
4087
+ ${import_chalk19.default.red(context.stack || context.message)}`;
3994
4088
  } else if (typeof context === "object") {
3995
4089
  try {
3996
4090
  output += `
3997
- ${import_chalk18.default.gray(JSON.stringify(context, null, 2))}`;
4091
+ ${import_chalk19.default.gray(JSON.stringify(context, null, 2))}`;
3998
4092
  } catch (e) {
3999
4093
  output += `
4000
- ${import_chalk18.default.gray("[Circular or invalid object]")}`;
4094
+ ${import_chalk19.default.gray("[Circular or invalid object]")}`;
4001
4095
  }
4002
4096
  } else {
4003
4097
  output += ` ${String(context)}`;
@@ -4025,7 +4119,7 @@ ${import_chalk18.default.gray("[Circular or invalid object]")}`;
4025
4119
  init_cjs_shims();
4026
4120
  var import_events3 = require("events");
4027
4121
  var import_chokidar = __toESM(require("chokidar"), 1);
4028
- var import_path19 = __toESM(require("path"), 1);
4122
+ var import_path20 = __toESM(require("path"), 1);
4029
4123
  var import_promises17 = __toESM(require("fs/promises"), 1);
4030
4124
  var import_crypto = __toESM(require("crypto"), 1);
4031
4125
  var import_axios15 = __toESM(require("axios"), 1);
@@ -4044,8 +4138,8 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4044
4138
  }
4045
4139
  async start() {
4046
4140
  await this.loadHashes();
4047
- const rulesPath = import_path19.default.join(this.config.watchPath, ".cursor", "rules");
4048
- 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");
4049
4143
  Logger.debug(`\u{1F33E} Harvester watching: ${watchPattern}`);
4050
4144
  this.watcher = import_chokidar.default.watch(watchPattern, {
4051
4145
  persistent: true,
@@ -4066,7 +4160,7 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4066
4160
  }
4067
4161
  }
4068
4162
  async handleFileEvent(filePath, event) {
4069
- const fileName = import_path19.default.basename(filePath);
4163
+ const fileName = import_path20.default.basename(filePath);
4070
4164
  if (this.IGNORED_PREFIXES.some((prefix) => fileName.startsWith(prefix))) {
4071
4165
  return;
4072
4166
  }
@@ -4085,24 +4179,24 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4085
4179
  const content = await import_promises17.default.readFile(filePath, "utf-8");
4086
4180
  const currentHash = this.computeHash(content);
4087
4181
  if (this.ruleHashes.get(filePath) === currentHash) {
4088
- Logger.debug(`Skipping ${import_path19.default.basename(filePath)} (unchanged hash)`);
4182
+ Logger.debug(`Skipping ${import_path20.default.basename(filePath)} (unchanged hash)`);
4089
4183
  return;
4090
4184
  }
4091
4185
  if (content.length < 20) {
4092
- Logger.debug(`Skipping ${import_path19.default.basename(filePath)} (too short)`);
4186
+ Logger.debug(`Skipping ${import_path20.default.basename(filePath)} (too short)`);
4093
4187
  return;
4094
4188
  }
4095
4189
  await this.submitSignal(filePath, content);
4096
4190
  this.ruleHashes.set(filePath, currentHash);
4097
4191
  } catch (error) {
4098
- 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}`);
4099
4193
  } finally {
4100
4194
  this.processingQueue.delete(filePath);
4101
4195
  }
4102
4196
  }
4103
4197
  async submitSignal(filePath, content) {
4104
- const title = import_path19.default.basename(filePath, ".mdc");
4105
- 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);
4106
4200
  Logger.info(`\u{1F33E} Harvesting new knowledge: ${title}`);
4107
4201
  try {
4108
4202
  const descriptionMatch = content.match(/description:\s*(.*)/);
@@ -4136,13 +4230,13 @@ var KnowledgeHarvester = class extends import_events3.EventEmitter {
4136
4230
  }
4137
4231
  }
4138
4232
  async loadHashes() {
4139
- const rulesPath = import_path19.default.join(this.config.watchPath, ".cursor", "rules");
4233
+ const rulesPath = import_path20.default.join(this.config.watchPath, ".cursor", "rules");
4140
4234
  try {
4141
4235
  await import_promises17.default.mkdir(rulesPath, { recursive: true });
4142
4236
  const files = await import_promises17.default.readdir(rulesPath);
4143
4237
  for (const file of files) {
4144
4238
  if (file.endsWith(".mdc")) {
4145
- const fullPath = import_path19.default.join(rulesPath, file);
4239
+ const fullPath = import_path20.default.join(rulesPath, file);
4146
4240
  const content = await import_promises17.default.readFile(fullPath, "utf-8");
4147
4241
  this.ruleHashes.set(fullPath, this.computeHash(content));
4148
4242
  }
@@ -4180,7 +4274,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4180
4274
  }
4181
4275
  async start() {
4182
4276
  if (this.state.isRunning) {
4183
- console.log(import_chalk19.default.yellow("Daemon is already running."));
4277
+ console.log(import_chalk20.default.yellow("Daemon is already running."));
4184
4278
  return;
4185
4279
  }
4186
4280
  this.printWelcome();
@@ -4212,8 +4306,8 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4212
4306
  try {
4213
4307
  await this.setupBridge();
4214
4308
  } catch (e) {
4215
- console.error(import_chalk19.default.yellow(` \u26A0\uFE0F Agent Bridge connection failed: ${e.message}`));
4216
- 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)"));
4217
4311
  }
4218
4312
  }
4219
4313
  this.printActive();
@@ -4229,16 +4323,16 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4229
4323
  }
4230
4324
  }
4231
4325
  printWelcome() {
4232
- console.log(import_chalk19.default.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
4233
- console.log(import_chalk19.default.dim(`Project: ${this.config.projectId}`));
4234
- console.log(import_chalk19.default.dim(`API URL: ${this.config.apiUrl}`));
4235
- console.log(import_chalk19.default.dim(`Watch Path: ${this.config.watchPath}`));
4236
- 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)));
4237
4331
  }
4238
4332
  printActive() {
4239
- console.log(import_chalk19.default.dim("\u2500".repeat(50)));
4240
- console.log(import_chalk19.default.green.bold("\u2705 Guardian Daemon is now active"));
4241
- 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"));
4242
4336
  }
4243
4337
  async syncHeuristics() {
4244
4338
  if (!this.heuristicEngine) return;
@@ -4261,7 +4355,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4261
4355
  }
4262
4356
  async getLineCount(filePath) {
4263
4357
  try {
4264
- const content = await fs18.readFile(filePath, "utf-8");
4358
+ const content = await fs19.readFile(filePath, "utf-8");
4265
4359
  return content.split("\n").length;
4266
4360
  } catch (e) {
4267
4361
  return 0;
@@ -4298,7 +4392,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4298
4392
  }
4299
4393
  }
4300
4394
  async updateViolationReport(violations) {
4301
- 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");
4302
4396
  const allViolations = Array.from(this.violationsMap.entries());
4303
4397
  const totalCount = allViolations.reduce((acc, [, v]) => acc + v.length, 0);
4304
4398
  let content = `# \u{1F6E1}\uFE0F Guardian Status: ${totalCount > 0 ? "\u26A0\uFE0F ATTENTION" : "\u2705 PASS"}
@@ -4314,7 +4408,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4314
4408
  } else {
4315
4409
  content += "### \u{1F6A8} Active Violations\n\n";
4316
4410
  for (const [file, fileViolations] of allViolations) {
4317
- const relPath = import_path20.default.relative(process.cwd(), file);
4411
+ const relPath = import_path21.default.relative(process.cwd(), file);
4318
4412
  content += `#### \u{1F4C4} ${relPath}
4319
4413
  `;
4320
4414
  for (const v of fileViolations) {
@@ -4326,7 +4420,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4326
4420
  content += "\n---\n*Rigstate Daemon is watching. Fix violations to clear this report.*";
4327
4421
  }
4328
4422
  try {
4329
- await fs18.writeFile(reportPath, content, "utf-8");
4423
+ await fs19.writeFile(reportPath, content, "utf-8");
4330
4424
  } catch (e) {
4331
4425
  }
4332
4426
  }
@@ -4346,27 +4440,27 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4346
4440
  }
4347
4441
  }
4348
4442
  async setupBridge() {
4349
- 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..."));
4350
4444
  this.bridgeListener = createBridgeListener(this.config.projectId, this.config.apiUrl, this.config.apiKey);
4351
4445
  this.bridgeListener.on("task", (task) => {
4352
4446
  this.state.lastActivity = (/* @__PURE__ */ new Date()).toISOString();
4353
4447
  this.state.tasksProcessed++;
4354
- console.log(import_chalk19.default.cyan(`
4448
+ console.log(import_chalk20.default.cyan(`
4355
4449
  \u{1F4E5} New task received: ${task.id}`));
4356
4450
  this.emit("task", task);
4357
4451
  });
4358
4452
  await this.bridgeListener.connect();
4359
- console.log(import_chalk19.default.green(" \u2713 Agent Bridge connected"));
4453
+ console.log(import_chalk20.default.green(" \u2713 Agent Bridge connected"));
4360
4454
  }
4361
4455
  async stop() {
4362
4456
  if (!this.state.isRunning) return;
4363
- 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..."));
4364
4458
  if (this.fileWatcher) await this.fileWatcher.stop();
4365
4459
  if (this.bridgeListener) await this.bridgeListener.disconnect();
4366
4460
  if (this.harvester) await this.harvester.stop();
4367
4461
  if (this.syncInterval) clearInterval(this.syncInterval);
4368
4462
  this.state.isRunning = false;
4369
- console.log(import_chalk19.default.green("\u2713 Daemon stopped."));
4463
+ console.log(import_chalk20.default.green("\u2713 Daemon stopped."));
4370
4464
  this.emit("stopped", this.state);
4371
4465
  }
4372
4466
  getState() {
@@ -4376,6 +4470,7 @@ var GuardianDaemon = class extends import_events4.EventEmitter {
4376
4470
 
4377
4471
  // src/daemon/factory.ts
4378
4472
  init_config();
4473
+ init_manifest();
4379
4474
  async function createDaemon(options) {
4380
4475
  const apiUrl = getApiUrl();
4381
4476
  let projectId = options.project;
@@ -4405,9 +4500,9 @@ async function createDaemon(options) {
4405
4500
 
4406
4501
  // src/utils/service-manager.ts
4407
4502
  init_cjs_shims();
4408
- var import_chalk20 = __toESM(require("chalk"), 1);
4503
+ var import_chalk21 = __toESM(require("chalk"), 1);
4409
4504
  var import_promises18 = __toESM(require("fs/promises"), 1);
4410
- var import_path21 = __toESM(require("path"), 1);
4505
+ var import_path22 = __toESM(require("path"), 1);
4411
4506
  var import_child_process3 = require("child_process");
4412
4507
  var import_url = require("url");
4413
4508
  async function execShellCommand(cmd) {
@@ -4419,20 +4514,20 @@ async function execShellCommand(cmd) {
4419
4514
  }
4420
4515
  }
4421
4516
  async function enableDaemon() {
4422
- 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"));
4423
4518
  if (process.platform !== "darwin") {
4424
- console.error(import_chalk20.default.red("\u274C Currently only macOS is supported for auto-start."));
4425
- 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!"));
4426
4521
  return;
4427
4522
  }
4428
4523
  const homeDir = process.env.HOME || "";
4429
4524
  if (!homeDir) {
4430
- 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."));
4431
4526
  return;
4432
4527
  }
4433
- const agentsDir = import_path21.default.join(homeDir, "Library/LaunchAgents");
4434
- const logDir = import_path21.default.join(homeDir, ".rigstate/logs");
4435
- 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");
4436
4531
  await import_promises18.default.mkdir(agentsDir, { recursive: true });
4437
4532
  await import_promises18.default.mkdir(logDir, { recursive: true });
4438
4533
  const scriptPath = (0, import_url.fileURLToPath)(importMetaUrl);
@@ -4453,9 +4548,9 @@ async function enableDaemon() {
4453
4548
  <key>WorkingDirectory</key>
4454
4549
  <string>${process.cwd()}</string>
4455
4550
  <key>StandardOutPath</key>
4456
- <string>${import_path21.default.join(logDir, "daemon.out.log")}</string>
4551
+ <string>${import_path22.default.join(logDir, "daemon.out.log")}</string>
4457
4552
  <key>StandardErrorPath</key>
4458
- <string>${import_path21.default.join(logDir, "daemon.err.log")}</string>
4553
+ <string>${import_path22.default.join(logDir, "daemon.err.log")}</string>
4459
4554
  <key>RunAtLoad</key>
4460
4555
  <true/>
4461
4556
  <key>KeepAlive</key>
@@ -4469,32 +4564,32 @@ async function enableDaemon() {
4469
4564
  </plist>`;
4470
4565
  try {
4471
4566
  await import_promises18.default.writeFile(plistPath, plistContent);
4472
- console.log(import_chalk20.default.dim(`Created plist at: ${plistPath}`));
4567
+ console.log(import_chalk21.default.dim(`Created plist at: ${plistPath}`));
4473
4568
  try {
4474
4569
  await execShellCommand(`launchctl unload ${plistPath}`);
4475
4570
  } catch (e) {
4476
4571
  }
4477
4572
  await execShellCommand(`launchctl load ${plistPath}`);
4478
- console.log(import_chalk20.default.green("\u2705 Successfully enabled background daemon!"));
4479
- console.log(import_chalk20.default.dim(`Logs: ${logDir}`));
4480
- 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."));
4481
4576
  } catch (error) {
4482
- 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);
4483
4578
  }
4484
4579
  }
4485
4580
  async function disableDaemon() {
4486
- 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"));
4487
4582
  const homeDir = process.env.HOME || "";
4488
- 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");
4489
4584
  try {
4490
4585
  await execShellCommand(`launchctl unload ${plistPath}`);
4491
4586
  await import_promises18.default.unlink(plistPath);
4492
- console.log(import_chalk20.default.green("\u2705 Successfully disabled background daemon."));
4587
+ console.log(import_chalk21.default.green("\u2705 Successfully disabled background daemon."));
4493
4588
  } catch (error) {
4494
4589
  if (error.code === "ENOENT") {
4495
- console.log(import_chalk20.default.green("\u2705 Daemon was not enabled."));
4590
+ console.log(import_chalk21.default.green("\u2705 Daemon was not enabled."));
4496
4591
  } else {
4497
- 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);
4498
4593
  }
4499
4594
  }
4500
4595
  }
@@ -4519,14 +4614,14 @@ function createDaemonCommand() {
4519
4614
  }
4520
4615
  const spinner = (0, import_ora8.default)();
4521
4616
  try {
4522
- const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
4617
+ const pidPath = import_path23.default.join(process.cwd(), PID_FILE);
4523
4618
  try {
4524
4619
  const content = await import_promises19.default.readFile(pidPath, "utf-8");
4525
4620
  const pid = parseInt(content.trim(), 10);
4526
4621
  try {
4527
4622
  process.kill(pid, 0);
4528
- console.log(import_chalk21.default.yellow("\u26A0 Another daemon instance is active (PID " + pid + ")."));
4529
- 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.
4530
4625
  `));
4531
4626
  } catch {
4532
4627
  await import_promises19.default.unlink(pidPath).catch(() => {
@@ -4544,7 +4639,7 @@ function createDaemonCommand() {
4544
4639
  spinner.stop();
4545
4640
  await writePidFile();
4546
4641
  process.on("SIGINT", async () => {
4547
- console.log(import_chalk21.default.dim("\n\nShutting down..."));
4642
+ console.log(import_chalk22.default.dim("\n\nShutting down..."));
4548
4643
  await daemonInstance.stop();
4549
4644
  await cleanupPidFile();
4550
4645
  process.exit(0);
@@ -4564,8 +4659,8 @@ function createDaemonCommand() {
4564
4659
  await new Promise(() => {
4565
4660
  });
4566
4661
  } catch (error) {
4567
- spinner.fail(import_chalk21.default.red("Failed to start daemon"));
4568
- 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);
4569
4664
  process.exit(1);
4570
4665
  }
4571
4666
  });
@@ -4573,7 +4668,7 @@ function createDaemonCommand() {
4573
4668
  }
4574
4669
  async function isRunning() {
4575
4670
  try {
4576
- const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
4671
+ const pidPath = import_path23.default.join(process.cwd(), PID_FILE);
4577
4672
  const content = await import_promises19.default.readFile(pidPath, "utf-8");
4578
4673
  const pid = parseInt(content.trim(), 10);
4579
4674
  try {
@@ -4589,57 +4684,57 @@ async function isRunning() {
4589
4684
  }
4590
4685
  async function writePidFile() {
4591
4686
  try {
4592
- const dir = import_path22.default.join(process.cwd(), ".rigstate");
4687
+ const dir = import_path23.default.join(process.cwd(), ".rigstate");
4593
4688
  await import_promises19.default.mkdir(dir, { recursive: true });
4594
- 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());
4595
4690
  } catch {
4596
4691
  }
4597
4692
  }
4598
4693
  async function cleanupPidFile() {
4599
4694
  try {
4600
- await import_promises19.default.unlink(import_path22.default.join(process.cwd(), PID_FILE));
4601
- 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));
4602
4697
  } catch {
4603
4698
  }
4604
4699
  }
4605
4700
  async function writeStateFile(state) {
4606
4701
  try {
4607
- const dir = import_path22.default.join(process.cwd(), ".rigstate");
4702
+ const dir = import_path23.default.join(process.cwd(), ".rigstate");
4608
4703
  await import_promises19.default.mkdir(dir, { recursive: true });
4609
4704
  await import_promises19.default.writeFile(
4610
- import_path22.default.join(dir, "daemon.state.json"),
4705
+ import_path23.default.join(dir, "daemon.state.json"),
4611
4706
  JSON.stringify(state, null, 2)
4612
4707
  );
4613
4708
  } catch {
4614
4709
  }
4615
4710
  }
4616
4711
  async function showStatus() {
4617
- 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"));
4618
4713
  const running = await isRunning();
4619
4714
  if (!running) {
4620
- console.log(import_chalk21.default.yellow("Status: Not running"));
4621
- 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'));
4622
4717
  return;
4623
4718
  }
4624
- console.log(import_chalk21.default.green("Status: Running"));
4719
+ console.log(import_chalk22.default.green("Status: Running"));
4625
4720
  try {
4626
- const statePath = import_path22.default.join(process.cwd(), STATE_FILE);
4721
+ const statePath = import_path23.default.join(process.cwd(), STATE_FILE);
4627
4722
  const content = await import_promises19.default.readFile(statePath, "utf-8");
4628
4723
  const state = JSON.parse(content);
4629
- console.log(import_chalk21.default.dim("\u2500".repeat(40)));
4724
+ console.log(import_chalk22.default.dim("\u2500".repeat(40)));
4630
4725
  console.log(`Started at: ${state.startedAt || "Unknown"}`);
4631
4726
  console.log(`Files checked: ${state.filesChecked || 0}`);
4632
4727
  console.log(`Violations: ${state.violationsFound || 0}`);
4633
4728
  console.log(`Tasks processed: ${state.tasksProcessed || 0}`);
4634
4729
  console.log(`Last activity: ${state.lastActivity || "None"}`);
4635
- console.log(import_chalk21.default.dim("\u2500".repeat(40)));
4730
+ console.log(import_chalk22.default.dim("\u2500".repeat(40)));
4636
4731
  } catch {
4637
- console.log(import_chalk21.default.dim("(State file not found)"));
4732
+ console.log(import_chalk22.default.dim("(State file not found)"));
4638
4733
  }
4639
4734
  try {
4640
- const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
4735
+ const pidPath = import_path23.default.join(process.cwd(), PID_FILE);
4641
4736
  const pid = await import_promises19.default.readFile(pidPath, "utf-8");
4642
- console.log(import_chalk21.default.dim(`PID: ${pid.trim()}`));
4737
+ console.log(import_chalk22.default.dim(`PID: ${pid.trim()}`));
4643
4738
  } catch {
4644
4739
  }
4645
4740
  console.log("");
@@ -4648,7 +4743,7 @@ async function showStatus() {
4648
4743
  // src/commands/work.ts
4649
4744
  init_cjs_shims();
4650
4745
  var import_commander13 = require("commander");
4651
- var import_chalk23 = __toESM(require("chalk"), 1);
4746
+ var import_chalk24 = __toESM(require("chalk"), 1);
4652
4747
  var import_ora10 = __toESM(require("ora"), 1);
4653
4748
  var import_axios17 = __toESM(require("axios"), 1);
4654
4749
  var import_inquirer3 = __toESM(require("inquirer"), 1);
@@ -4658,11 +4753,11 @@ init_suggest();
4658
4753
  // src/commands/plan.ts
4659
4754
  init_cjs_shims();
4660
4755
  var import_commander12 = require("commander");
4661
- var import_chalk22 = __toESM(require("chalk"), 1);
4756
+ var import_chalk23 = __toESM(require("chalk"), 1);
4662
4757
  var import_ora9 = __toESM(require("ora"), 1);
4663
4758
  var import_axios16 = __toESM(require("axios"), 1);
4664
4759
  var import_promises20 = __toESM(require("fs/promises"), 1);
4665
- var import_path23 = __toESM(require("path"), 1);
4760
+ var import_path24 = __toESM(require("path"), 1);
4666
4761
  var import_inquirer2 = __toESM(require("inquirer"), 1);
4667
4762
  init_config();
4668
4763
  function createPlanCommand() {
@@ -4721,7 +4816,7 @@ async function executePlan(taskId) {
4721
4816
  taskDescription = task.description;
4722
4817
  }
4723
4818
  spinner.start("Generating Context for Frank...");
4724
- 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");
4725
4820
  const contextContent = `
4726
4821
  # \u{1F3AF} Active Mission: ${taskTitle}
4727
4822
  **ID:** ${taskId}
@@ -4736,9 +4831,9 @@ ${taskDescription}
4736
4831
 
4737
4832
  *Generated by Rigstate CLI at ${(/* @__PURE__ */ new Date()).toLocaleString()}*
4738
4833
  `;
4739
- 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 });
4740
4835
  await import_promises20.default.writeFile(contextPath, contextContent.trim());
4741
- const planPath = import_path23.default.join(process.cwd(), "IMPLEMENTATION_PLAN.md");
4836
+ const planPath = import_path24.default.join(process.cwd(), "IMPLEMENTATION_PLAN.md");
4742
4837
  const planExists = await import_promises20.default.stat(planPath).then(() => true).catch(() => false);
4743
4838
  if (!planExists) {
4744
4839
  const planTemplate = `
@@ -4759,22 +4854,37 @@ ${taskDescription}
4759
4854
  [Frank: Log your progress here]
4760
4855
  `;
4761
4856
  await import_promises20.default.writeFile(planPath, planTemplate.trim());
4762
- spinner.succeed(import_chalk22.default.green("Created new IMPLEMENTATION_PLAN.md"));
4857
+ spinner.succeed(import_chalk23.default.green("Created new IMPLEMENTATION_PLAN.md"));
4763
4858
  } else {
4764
- 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)."));
4765
4875
  }
4766
4876
  console.log("");
4767
- console.log(import_chalk22.default.bold.blue("\u{1F680} Planning Mode Activated"));
4768
- 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"));
4769
- console.log(`1. Context loaded into: ${import_chalk22.default.bold(".rigstate/CURRENT_CONTEXT.md")}`);
4770
- 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")}`);
4771
4881
  console.log("");
4772
- console.log(import_chalk22.default.yellow("\u{1F449} NEXT STEP:"));
4773
- console.log(` Open ${import_chalk22.default.bold("IMPLEMENTATION_PLAN.md")} in your IDE.`);
4774
- 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."));
4775
4885
  console.log("");
4776
4886
  } catch (e) {
4777
- spinner.fail(import_chalk22.default.red(`Planning failed: ${e.message}`));
4887
+ spinner.fail(import_chalk23.default.red(`Planning failed: ${e.message}`));
4778
4888
  }
4779
4889
  }
4780
4890
  function getContext() {
@@ -4819,7 +4929,7 @@ async function listInteractive() {
4819
4929
  });
4820
4930
  spinner.stop();
4821
4931
  if (actionableTasks.length === 0) {
4822
- 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."));
4823
4933
  return;
4824
4934
  }
4825
4935
  const choices = actionableTasks.map((t) => {
@@ -4828,7 +4938,7 @@ async function listInteractive() {
4828
4938
  if (t.status === "IN_PROGRESS") icon = "\u{1F525}";
4829
4939
  if (t.status === "ACTIVE") icon = "\u25B6\uFE0F";
4830
4940
  return {
4831
- name: `${icon} ${import_chalk23.default.bold(id)}: ${t.title} [${t.status}]`,
4941
+ name: `${icon} ${import_chalk24.default.bold(id)}: ${t.title} [${t.status}]`,
4832
4942
  value: t.id
4833
4943
  };
4834
4944
  });
@@ -4875,25 +4985,25 @@ async function setTaskStatus(taskId, status) {
4875
4985
  { step_id: realId, status, project_id: projectId },
4876
4986
  { headers: { "Authorization": `Bearer ${apiKey}` } }
4877
4987
  );
4878
- spinner.succeed(import_chalk23.default.green(`Task updated to ${status}.`));
4988
+ spinner.succeed(import_chalk24.default.green(`Task updated to ${status}.`));
4879
4989
  if (status === "IN_PROGRESS") {
4880
- console.log(import_chalk23.default.blue(`
4990
+ console.log(import_chalk24.default.blue(`
4881
4991
  \u{1F4A1} Tip: Provide 'Frank' with context by mentioning @.cursorrules in your chat.`));
4882
4992
  }
4883
4993
  } catch (e) {
4884
- spinner.fail(import_chalk23.default.red(`Failed: ${e.message}`));
4994
+ spinner.fail(import_chalk24.default.red(`Failed: ${e.message}`));
4885
4995
  }
4886
4996
  }
4887
4997
  async function finishTask(taskId) {
4888
4998
  console.log("");
4889
- console.log(import_chalk23.default.bold.yellow("\u{1F6E1}\uFE0F FRANK'S QUALITY GATE"));
4890
- 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"));
4891
5001
  const auditSpinner = (0, import_ora10.default)(" Analyzing architectural integrity...").start();
4892
5002
  await new Promise((r) => setTimeout(r, 1500));
4893
5003
  auditSpinner.succeed("Architecture: VALIDATED (SEC-ARCH-01 Pass)");
4894
5004
  await setTaskStatus(taskId, "COMPLETED");
4895
5005
  console.log("");
4896
- 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."));
4897
5007
  const { projectId, apiKey, apiUrl } = getContext2();
4898
5008
  await suggestNextMove(projectId, apiKey, apiUrl);
4899
5009
  }
@@ -4910,40 +5020,36 @@ function getContext2() {
4910
5020
  // src/commands/watch.ts
4911
5021
  init_cjs_shims();
4912
5022
  var import_commander14 = require("commander");
4913
- var import_chalk24 = __toESM(require("chalk"), 1);
5023
+ var import_chalk25 = __toESM(require("chalk"), 1);
4914
5024
  var import_ora11 = __toESM(require("ora"), 1);
4915
5025
  var import_chokidar2 = __toESM(require("chokidar"), 1);
4916
5026
  var import_promises21 = __toESM(require("fs/promises"), 1);
4917
- var import_path24 = __toESM(require("path"), 1);
5027
+ var import_path25 = __toESM(require("path"), 1);
4918
5028
  var import_child_process4 = require("child_process");
4919
5029
  init_config();
4920
5030
  var import_axios18 = __toESM(require("axios"), 1);
4921
5031
  function createWatchCommand() {
4922
5032
  const watch2 = new import_commander14.Command("watch");
4923
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) => {
4924
- console.log(import_chalk24.default.bold.blue("\u{1F52D} Rigstate Watch Mode"));
4925
- 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..."));
4926
5036
  console.log("");
4927
5037
  let apiKey;
4928
5038
  let projectId;
4929
5039
  try {
4930
5040
  apiKey = getApiKey();
4931
5041
  } catch (e) {
4932
- 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.'));
4933
5043
  return;
4934
5044
  }
4935
5045
  projectId = getProjectId();
4936
5046
  if (!projectId) {
4937
- try {
4938
- const manifestPath = import_path24.default.join(process.cwd(), ".rigstate");
4939
- const content = await import_promises21.default.readFile(manifestPath, "utf-8");
4940
- const manifest = JSON.parse(content);
4941
- projectId = manifest.project_id;
4942
- } catch (e) {
4943
- }
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;
4944
5050
  }
4945
5051
  if (!projectId) {
4946
- 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.'));
4947
5053
  return;
4948
5054
  }
4949
5055
  const apiUrl = getApiUrl();
@@ -4953,8 +5059,8 @@ function createWatchCommand() {
4953
5059
  runTests: options.runTests || false,
4954
5060
  testCommand: options.testCommand || "npm test"
4955
5061
  };
4956
- console.log(import_chalk24.default.dim(`Auto-commit: ${config2.autoCommit ? "ON" : "OFF"}`));
4957
- 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"}`));
4958
5064
  console.log("");
4959
5065
  const fetchActiveTask = async () => {
4960
5066
  try {
@@ -4982,7 +5088,7 @@ function createWatchCommand() {
4982
5088
  };
4983
5089
  const checkCriteria = async (criteria) => {
4984
5090
  try {
4985
- const fullPath = import_path24.default.resolve(process.cwd(), criteria.path);
5091
+ const fullPath = import_path25.default.resolve(process.cwd(), criteria.path);
4986
5092
  switch (criteria.type) {
4987
5093
  case "file_exists":
4988
5094
  await import_promises21.default.access(fullPath);
@@ -5021,7 +5127,7 @@ function createWatchCommand() {
5021
5127
  }, {
5022
5128
  headers: { Authorization: `Bearer ${apiKey}` }
5023
5129
  });
5024
- 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}`));
5025
5131
  if (config2.autoCommit) {
5026
5132
  spinner.start("Committing changes...");
5027
5133
  try {
@@ -5043,7 +5149,7 @@ function createWatchCommand() {
5043
5149
  }
5044
5150
  }
5045
5151
  console.log("");
5046
- console.log(import_chalk24.default.blue("Watching for next task..."));
5152
+ console.log(import_chalk25.default.blue("Watching for next task..."));
5047
5153
  } catch (e) {
5048
5154
  spinner.fail(`Failed to complete task: ${e.message}`);
5049
5155
  }
@@ -5056,7 +5162,7 @@ function createWatchCommand() {
5056
5162
  const task = await fetchActiveTask();
5057
5163
  if (!task) {
5058
5164
  if (currentTask) {
5059
- 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..."));
5060
5166
  currentTask = null;
5061
5167
  }
5062
5168
  isProcessing = false;
@@ -5065,10 +5171,10 @@ function createWatchCommand() {
5065
5171
  if (!currentTask || currentTask.id !== task.id) {
5066
5172
  currentTask = task;
5067
5173
  console.log("");
5068
- console.log(import_chalk24.default.bold.yellow(`\u{1F4CC} Active Task #${task.step_number}: ${task.title}`));
5069
- 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}`));
5070
5176
  if (task.verification_criteria) {
5071
- console.log(import_chalk24.default.dim("Verification: Auto-checking criteria..."));
5177
+ console.log(import_chalk25.default.dim("Verification: Auto-checking criteria..."));
5072
5178
  }
5073
5179
  }
5074
5180
  if (task.verification_criteria && Array.isArray(task.verification_criteria)) {
@@ -5081,7 +5187,7 @@ function createWatchCommand() {
5081
5187
  }
5082
5188
  }
5083
5189
  if (allPassed) {
5084
- console.log(import_chalk24.default.green("\u2713 All verification criteria passed!"));
5190
+ console.log(import_chalk25.default.green("\u2713 All verification criteria passed!"));
5085
5191
  await completeTask(task.id, task);
5086
5192
  currentTask = null;
5087
5193
  }
@@ -5106,11 +5212,11 @@ function createWatchCommand() {
5106
5212
  setTimeout(() => processActiveTask(), 500);
5107
5213
  }
5108
5214
  });
5109
- 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)"));
5110
5216
  setInterval(() => processActiveTask(), 3e4);
5111
5217
  process.on("SIGINT", () => {
5112
5218
  console.log("");
5113
- console.log(import_chalk24.default.dim("Watch mode stopped."));
5219
+ console.log(import_chalk25.default.dim("Watch mode stopped."));
5114
5220
  watcher.close();
5115
5221
  process.exit(0);
5116
5222
  });
@@ -5121,13 +5227,11 @@ function createWatchCommand() {
5121
5227
  // src/commands/focus.ts
5122
5228
  init_cjs_shims();
5123
5229
  var import_commander15 = require("commander");
5124
- var import_chalk25 = __toESM(require("chalk"), 1);
5230
+ var import_chalk26 = __toESM(require("chalk"), 1);
5125
5231
  var import_ora12 = __toESM(require("ora"), 1);
5126
5232
  init_config();
5127
5233
  var import_axios19 = __toESM(require("axios"), 1);
5128
5234
  var import_child_process5 = require("child_process");
5129
- var import_promises22 = __toESM(require("fs/promises"), 1);
5130
- var import_path25 = __toESM(require("path"), 1);
5131
5235
  function createFocusCommand() {
5132
5236
  const focus = new import_commander15.Command("focus");
5133
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) => {
@@ -5137,21 +5241,17 @@ function createFocusCommand() {
5137
5241
  try {
5138
5242
  apiKey = getApiKey();
5139
5243
  } catch (e) {
5140
- 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.'));
5141
5245
  return;
5142
5246
  }
5143
5247
  projectId = getProjectId();
5144
5248
  if (!projectId) {
5145
- try {
5146
- const manifestPath = import_path25.default.join(process.cwd(), ".rigstate");
5147
- const content = await import_promises22.default.readFile(manifestPath, "utf-8");
5148
- const manifest = JSON.parse(content);
5149
- projectId = manifest.project_id;
5150
- } catch (e) {
5151
- }
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;
5152
5252
  }
5153
5253
  if (!projectId) {
5154
- 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.'));
5155
5255
  return;
5156
5256
  }
5157
5257
  const apiUrl = getApiUrl();
@@ -5182,41 +5282,41 @@ function createFocusCommand() {
5182
5282
  const nextTask = activeTasks[0];
5183
5283
  spinner.stop();
5184
5284
  console.log("");
5185
- console.log(import_chalk25.default.bold.blue(`\u{1F4CC} Task #${nextTask.step_number || "?"}: ${nextTask.title}`));
5186
- const statusColor = nextTask.status === "IN_PROGRESS" ? import_chalk25.default.yellow : nextTask.status === "ACTIVE" ? import_chalk25.default.green : import_chalk25.default.dim;
5187
- console.log(import_chalk25.default.dim("Status: ") + statusColor(nextTask.status));
5188
- 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)));
5189
5289
  if (nextTask.prompt_content) {
5190
- console.log(import_chalk25.default.white(nextTask.prompt_content));
5191
- 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)));
5192
5292
  if (options.copy !== false) {
5193
5293
  try {
5194
5294
  if (process.platform === "darwin") {
5195
5295
  (0, import_child_process5.execSync)("pbcopy", { input: nextTask.prompt_content });
5196
- 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)."));
5197
5297
  } else if (process.platform === "linux") {
5198
5298
  try {
5199
5299
  (0, import_child_process5.execSync)("xclip -selection clipboard", { input: nextTask.prompt_content });
5200
- console.log(import_chalk25.default.green("\u2705 Prompt copied to clipboard!"));
5300
+ console.log(import_chalk26.default.green("\u2705 Prompt copied to clipboard!"));
5201
5301
  } catch (e) {
5202
- 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)"));
5203
5303
  }
5204
5304
  } else {
5205
- 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)"));
5206
5306
  }
5207
5307
  } catch (e) {
5208
5308
  }
5209
5309
  }
5210
5310
  } else {
5211
- console.log(import_chalk25.default.yellow("No prompt instructions available."));
5311
+ console.log(import_chalk26.default.yellow("No prompt instructions available."));
5212
5312
  if (nextTask.architectural_brief) {
5213
- console.log(import_chalk25.default.bold("Brief:"));
5313
+ console.log(import_chalk26.default.bold("Brief:"));
5214
5314
  console.log(nextTask.architectural_brief);
5215
5315
  }
5216
5316
  }
5217
5317
  console.log("");
5218
5318
  } catch (e) {
5219
- 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}`));
5220
5320
  }
5221
5321
  });
5222
5322
  return focus;
@@ -5228,26 +5328,26 @@ init_env();
5228
5328
  // src/commands/config.ts
5229
5329
  init_cjs_shims();
5230
5330
  var import_commander16 = require("commander");
5231
- var import_chalk26 = __toESM(require("chalk"), 1);
5331
+ var import_chalk27 = __toESM(require("chalk"), 1);
5232
5332
  init_config();
5233
5333
  function createConfigCommand() {
5234
5334
  const config2 = new import_commander16.Command("config");
5235
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) => {
5236
5336
  if (!key) {
5237
- console.log(import_chalk26.default.bold("Rigstate Configuration"));
5238
- 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)));
5239
5339
  try {
5240
5340
  const apiKey = getApiKey();
5241
- 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)}...`);
5242
5342
  } catch (e) {
5243
- 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)")}`);
5244
5344
  }
5245
5345
  const projectId = getProjectId();
5246
- 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)")}`);
5247
5347
  const apiUrl = getApiUrl();
5248
- console.log(`${import_chalk26.default.cyan("api_url")}: ${apiUrl}`);
5348
+ console.log(`${import_chalk27.default.cyan("api_url")}: ${apiUrl}`);
5249
5349
  console.log("");
5250
- 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.'));
5251
5351
  return;
5252
5352
  }
5253
5353
  if (!value) {
@@ -5257,37 +5357,37 @@ function createConfigCommand() {
5257
5357
  const apiKey = getApiKey();
5258
5358
  console.log(apiKey);
5259
5359
  } catch (e) {
5260
- console.log(import_chalk26.default.dim("(not set)"));
5360
+ console.log(import_chalk27.default.dim("(not set)"));
5261
5361
  }
5262
5362
  break;
5263
5363
  case "project_id":
5264
- console.log(getProjectId() || import_chalk26.default.dim("(not set)"));
5364
+ console.log(getProjectId() || import_chalk27.default.dim("(not set)"));
5265
5365
  break;
5266
5366
  case "api_url":
5267
5367
  console.log(getApiUrl());
5268
5368
  break;
5269
5369
  default:
5270
- console.log(import_chalk26.default.red(`Unknown config key: ${key}`));
5271
- 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"));
5272
5372
  }
5273
5373
  return;
5274
5374
  }
5275
5375
  switch (key) {
5276
5376
  case "api_key":
5277
5377
  setApiKey(value);
5278
- console.log(import_chalk26.default.green(`\u2705 api_key updated`));
5378
+ console.log(import_chalk27.default.green(`\u2705 api_key updated`));
5279
5379
  break;
5280
5380
  case "project_id":
5281
5381
  setProjectId(value);
5282
- console.log(import_chalk26.default.green(`\u2705 project_id updated`));
5382
+ console.log(import_chalk27.default.green(`\u2705 project_id updated`));
5283
5383
  break;
5284
5384
  case "api_url":
5285
5385
  setApiUrl(value);
5286
- console.log(import_chalk26.default.green(`\u2705 api_url updated`));
5386
+ console.log(import_chalk27.default.green(`\u2705 api_url updated`));
5287
5387
  break;
5288
5388
  default:
5289
- console.log(import_chalk26.default.red(`Unknown config key: ${key}`));
5290
- 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"));
5291
5391
  }
5292
5392
  });
5293
5393
  return config2;
@@ -5296,10 +5396,10 @@ function createConfigCommand() {
5296
5396
  // src/commands/mcp.ts
5297
5397
  init_cjs_shims();
5298
5398
  var import_commander17 = require("commander");
5299
- var import_chalk27 = __toESM(require("chalk"), 1);
5399
+ var import_chalk28 = __toESM(require("chalk"), 1);
5300
5400
  var import_child_process6 = require("child_process");
5301
5401
  var import_path26 = __toESM(require("path"), 1);
5302
- var import_fs = __toESM(require("fs"), 1);
5402
+ var import_fs3 = __toESM(require("fs"), 1);
5303
5403
  var import_url2 = require("url");
5304
5404
  init_config();
5305
5405
  var __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
@@ -5317,21 +5417,21 @@ function createMcpCommand() {
5317
5417
  ];
5318
5418
  let serverPath = "";
5319
5419
  for (const p of possiblePaths) {
5320
- if (import_fs.default.existsSync(p)) {
5420
+ if (import_fs3.default.existsSync(p)) {
5321
5421
  serverPath = p;
5322
5422
  break;
5323
5423
  }
5324
5424
  }
5325
5425
  if (!serverPath) {
5326
- console.error(import_chalk27.default.red("\u274C Error: Rigstate MCP Server binary not found."));
5327
- console.error(import_chalk27.default.yellow("Please ensure that the mcp package is built:"));
5328
- 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"));
5329
5429
  console.error("");
5330
- console.error(import_chalk27.default.dim("Or run directly with:"));
5331
- 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"));
5332
5432
  process.exit(1);
5333
5433
  }
5334
- console.log(import_chalk27.default.dim(`Starting MCP server from: ${serverPath}`));
5434
+ console.log(import_chalk28.default.dim(`Starting MCP server from: ${serverPath}`));
5335
5435
  const env = { ...process.env };
5336
5436
  try {
5337
5437
  const apiKey = getApiKey();
@@ -5350,7 +5450,7 @@ function createMcpCommand() {
5350
5450
  stdio: ["inherit", "inherit", "inherit"]
5351
5451
  });
5352
5452
  worker.on("error", (err) => {
5353
- 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}`));
5354
5454
  process.exit(1);
5355
5455
  });
5356
5456
  worker.on("exit", (code) => {
@@ -5365,7 +5465,7 @@ function createMcpCommand() {
5365
5465
  // src/commands/nexus.ts
5366
5466
  init_cjs_shims();
5367
5467
  var import_commander18 = require("commander");
5368
- var import_chalk29 = __toESM(require("chalk"), 1);
5468
+ var import_chalk30 = __toESM(require("chalk"), 1);
5369
5469
 
5370
5470
  // src/nexus/dispatcher.ts
5371
5471
  init_cjs_shims();
@@ -5433,7 +5533,7 @@ var HiveScrubber = class {
5433
5533
  };
5434
5534
 
5435
5535
  // src/hive/gateway.ts
5436
- var import_chalk28 = __toESM(require("chalk"), 1);
5536
+ var import_chalk29 = __toESM(require("chalk"), 1);
5437
5537
  var HiveGateway = class {
5438
5538
  client;
5439
5539
  enabled;
@@ -5443,7 +5543,7 @@ var HiveGateway = class {
5443
5543
  constructor(baseUrl, token) {
5444
5544
  this.enabled = !!token;
5445
5545
  if (!this.enabled) {
5446
- 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."));
5447
5547
  }
5448
5548
  this.client = import_axios20.default.create({
5449
5549
  baseURL: baseUrl,
@@ -5463,23 +5563,23 @@ var HiveGateway = class {
5463
5563
  if (!this.enabled) return false;
5464
5564
  const now = Date.now();
5465
5565
  if (now - this.lastSignalTime < this.MIN_INTERVAL_MS) {
5466
- 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."));
5467
5567
  return false;
5468
5568
  }
5469
5569
  const scrubResult = HiveScrubber.scrub(signal.ruleContent);
5470
5570
  if (scrubResult.riskScore > 20) {
5471
- 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})`));
5472
5572
  return false;
5473
5573
  }
5474
5574
  try {
5475
- 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}]`));
5476
5576
  const payload = { ...signal, ruleContent: scrubResult.sanitizedContent };
5477
5577
  await this.client.post("/signal", payload);
5478
5578
  this.lastSignalTime = now;
5479
- 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."));
5480
5580
  return true;
5481
5581
  } catch (error) {
5482
- 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}`));
5483
5583
  return false;
5484
5584
  }
5485
5585
  }
@@ -5581,10 +5681,10 @@ var import_inquirer4 = __toESM(require("inquirer"), 1);
5581
5681
  function createNexusCommand() {
5582
5682
  const command = new import_commander18.Command("nexus");
5583
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) => {
5584
- 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"));
5585
5685
  const dryRun = !options.force;
5586
5686
  if (!dryRun) {
5587
- 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."));
5588
5688
  const { confirm } = await import_inquirer4.default.prompt([{
5589
5689
  type: "confirm",
5590
5690
  name: "confirm",
@@ -5605,26 +5705,26 @@ function createNexusCommand() {
5605
5705
  };
5606
5706
  const dispatcher = new NexusDispatcher(context);
5607
5707
  dispatcher.on("order:created", (o) => {
5608
- 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);
5609
5709
  });
5610
5710
  dispatcher.on("order:started", (o) => {
5611
- 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...`));
5612
5712
  });
5613
5713
  dispatcher.on("order:blocked", (o) => {
5614
- console.log(import_chalk29.default.red(`\u{1F6D1} [${o.id.slice(0, 6)}] BLOCKED by Kill-Switch`));
5615
- console.log(import_chalk29.default.dim(` Target: ${o.targetAgent} | Action: ${o.action}`));
5616
- 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)."));
5617
5717
  });
5618
- dispatcher.on("agent:SINDRE", (o) => console.log(import_chalk29.default.cyan(`\u{1F916} Sindre (Vault): I'm on it! (${o.action})`)));
5619
- dispatcher.on("agent:EITRI", (o) => console.log(import_chalk29.default.green(`\u{1F477} Eitri (Smith): Ready to build! (${o.action})`)));
5620
- 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..."));
5621
5721
  await new Promise((r) => setTimeout(r, 800));
5622
5722
  if (intent.toLowerCase().includes("db") || intent.toLowerCase().includes("database")) {
5623
5723
  await dispatcher.dispatch("FRANK", "SINDRE", intent, "db.analyze", { raw: intent });
5624
5724
  } else if (intent.toLowerCase().includes("create") || intent.toLowerCase().includes("code")) {
5625
5725
  await dispatcher.dispatch("FRANK", "EITRI", intent, "fs.write", { path: "src/demo.ts", content: "// demo" });
5626
5726
  } else {
5627
- 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'."));
5628
5728
  }
5629
5729
  });
5630
5730
  return command;
@@ -5636,7 +5736,7 @@ init_sync_rules();
5636
5736
  // src/commands/override.ts
5637
5737
  init_cjs_shims();
5638
5738
  var import_commander19 = require("commander");
5639
- var import_chalk30 = __toESM(require("chalk"), 1);
5739
+ var import_chalk31 = __toESM(require("chalk"), 1);
5640
5740
  init_governance();
5641
5741
  init_config();
5642
5742
  var import_axios21 = __toESM(require("axios"), 1);
@@ -5644,19 +5744,19 @@ function createOverrideCommand() {
5644
5744
  const override = new import_commander19.Command("override");
5645
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) => {
5646
5746
  const { reason } = options;
5647
- console.log(import_chalk30.default.bold(`
5747
+ console.log(import_chalk31.default.bold(`
5648
5748
  \u{1F513} Initiating Governance Override Protocol...`));
5649
5749
  const session = await getSessionState(process.cwd());
5650
5750
  if (session.status !== "SOFT_LOCK") {
5651
- 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."));
5652
5752
  return;
5653
5753
  }
5654
- console.log(import_chalk30.default.dim(` Active Violation: ${session.active_violation}`));
5655
- 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}"`));
5656
5756
  const success = await performOverride(violationId, reason, process.cwd());
5657
5757
  if (success) {
5658
- console.log(import_chalk30.default.green(` \u2705 Session UNLOCKED.`));
5659
- 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.`));
5660
5760
  try {
5661
5761
  const projectId = getProjectId();
5662
5762
  if (projectId) {
@@ -5673,13 +5773,13 @@ function createOverrideCommand() {
5673
5773
  }, {
5674
5774
  headers: { Authorization: `Bearer ${apiKey}` }
5675
5775
  });
5676
- 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.`));
5677
5777
  }
5678
5778
  } catch (e) {
5679
- 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})`));
5680
5780
  }
5681
5781
  } else {
5682
- 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.`));
5683
5783
  }
5684
5784
  });
5685
5785
  return override;
@@ -5688,7 +5788,7 @@ function createOverrideCommand() {
5688
5788
  // src/commands/idea.ts
5689
5789
  init_cjs_shims();
5690
5790
  var import_commander20 = require("commander");
5691
- var import_chalk31 = __toESM(require("chalk"), 1);
5791
+ var import_chalk32 = __toESM(require("chalk"), 1);
5692
5792
  var import_ora13 = __toESM(require("ora"), 1);
5693
5793
  var import_axios22 = __toESM(require("axios"), 1);
5694
5794
  var import_inquirer5 = __toESM(require("inquirer"), 1);
@@ -5700,7 +5800,7 @@ function createIdeaCommand() {
5700
5800
  const apiUrl = getApiUrl();
5701
5801
  const projectId = getProjectId();
5702
5802
  if (!projectId) {
5703
- 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."));
5704
5804
  process.exit(1);
5705
5805
  }
5706
5806
  let ideaTitle = title;
@@ -5736,14 +5836,14 @@ function createIdeaCommand() {
5736
5836
  { headers: { Authorization: `Bearer ${apiKey}` } }
5737
5837
  );
5738
5838
  if (response.data.success) {
5739
- spinner.succeed(import_chalk31.default.green("Idea Captured! \u{1F4A1}"));
5740
- 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"}`));
5741
5841
  } else {
5742
5842
  throw new Error(response.data.error);
5743
5843
  }
5744
5844
  } catch (e) {
5745
5845
  const errorDetail = e.response?.data?.error || e.message;
5746
- console.error(import_chalk31.default.red(`
5846
+ console.error(import_chalk32.default.red(`
5747
5847
  Failed to capture idea: ${errorDetail}`));
5748
5848
  }
5749
5849
  });
@@ -5752,10 +5852,10 @@ Failed to capture idea: ${errorDetail}`));
5752
5852
  // src/commands/release.ts
5753
5853
  init_cjs_shims();
5754
5854
  var import_commander21 = require("commander");
5755
- var import_chalk32 = __toESM(require("chalk"), 1);
5855
+ var import_chalk33 = __toESM(require("chalk"), 1);
5756
5856
  var import_ora14 = __toESM(require("ora"), 1);
5757
5857
  var import_inquirer6 = __toESM(require("inquirer"), 1);
5758
- var import_promises23 = __toESM(require("fs/promises"), 1);
5858
+ var import_promises22 = __toESM(require("fs/promises"), 1);
5759
5859
  var import_path27 = __toESM(require("path"), 1);
5760
5860
  init_config();
5761
5861
 
@@ -10321,7 +10421,7 @@ function createReleaseCommand() {
10321
10421
  }
10322
10422
  spinner.text = "Scanning completed tasks...";
10323
10423
  const pkgPath = import_path27.default.resolve(process.cwd(), "package.json");
10324
- const pkgContent = await import_promises23.default.readFile(pkgPath, "utf-8");
10424
+ const pkgContent = await import_promises22.default.readFile(pkgPath, "utf-8");
10325
10425
  const pkg2 = JSON.parse(pkgContent);
10326
10426
  const currentVersion = pkg2.version;
10327
10427
  const [major, minor, patch] = currentVersion.split(".").map(Number);
@@ -10329,7 +10429,7 @@ function createReleaseCommand() {
10329
10429
  if (type === "major") newVersion = `${major + 1}.0.0`;
10330
10430
  if (type === "minor") newVersion = `${major}.${minor + 1}.0`;
10331
10431
  if (type === "patch") newVersion = `${major}.${minor}.${patch + 1}`;
10332
- 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)}`);
10333
10433
  const { confirm } = await import_inquirer6.default.prompt([{
10334
10434
  type: "confirm",
10335
10435
  name: "confirm",
@@ -10341,7 +10441,7 @@ function createReleaseCommand() {
10341
10441
  return;
10342
10442
  }
10343
10443
  pkg2.version = newVersion;
10344
- await import_promises23.default.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
10444
+ await import_promises22.default.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
10345
10445
  const changelogPath = import_path27.default.resolve(process.cwd(), "CHANGELOG.md");
10346
10446
  const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
10347
10447
  const entry = `
@@ -10349,9 +10449,9 @@ function createReleaseCommand() {
10349
10449
  - Automated release via Rigstate.
10350
10450
  `;
10351
10451
  try {
10352
- await import_promises23.default.appendFile(changelogPath, entry);
10452
+ await import_promises22.default.appendFile(changelogPath, entry);
10353
10453
  } catch {
10354
- await import_promises23.default.writeFile(changelogPath, "# Changelog\n" + entry);
10454
+ await import_promises22.default.writeFile(changelogPath, "# Changelog\n" + entry);
10355
10455
  }
10356
10456
  spinner.start("Tagging and pushing...");
10357
10457
  await git.add(["package.json", "CHANGELOG.md"]);
@@ -10359,7 +10459,7 @@ function createReleaseCommand() {
10359
10459
  await git.addTag(`v${newVersion}`);
10360
10460
  await git.push();
10361
10461
  await git.pushTags();
10362
- 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!`));
10363
10463
  } catch (e) {
10364
10464
  spinner.fail(e.message);
10365
10465
  }
@@ -10376,7 +10476,7 @@ function getContext3() {
10376
10476
  // src/commands/roadmap.ts
10377
10477
  init_cjs_shims();
10378
10478
  var import_commander22 = require("commander");
10379
- var import_chalk33 = __toESM(require("chalk"), 1);
10479
+ var import_chalk34 = __toESM(require("chalk"), 1);
10380
10480
  var import_ora15 = __toESM(require("ora"), 1);
10381
10481
  var import_axios23 = __toESM(require("axios"), 1);
10382
10482
  init_config();
@@ -10388,7 +10488,7 @@ function createRoadmapCommand() {
10388
10488
  const apiUrl = getApiUrl();
10389
10489
  const projectId = getProjectId();
10390
10490
  if (!projectId) {
10391
- 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".'));
10392
10492
  return;
10393
10493
  }
10394
10494
  const response = await import_axios23.default.get(
@@ -10401,11 +10501,11 @@ function createRoadmapCommand() {
10401
10501
  const tasks = response.data.data.roadmap || [];
10402
10502
  spinner.stop();
10403
10503
  if (tasks.length === 0) {
10404
- 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."));
10405
10505
  return;
10406
10506
  }
10407
- console.log("\n" + import_chalk33.default.bold.underline("\u{1F6F0}\uFE0F TACTICAL OVERVIEW: PROJECT ROADMAP"));
10408
- 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"));
10409
10509
  const columns = {
10410
10510
  "IN_PROGRESS": [],
10411
10511
  "ACTIVE": [],
@@ -10417,14 +10517,14 @@ function createRoadmapCommand() {
10417
10517
  columns[t.status].push(t);
10418
10518
  }
10419
10519
  });
10420
- displayColumn("\u{1F525} IN PROGRESS", columns.IN_PROGRESS, import_chalk33.default.yellow);
10421
- displayColumn("\u25B6\uFE0F ACTIVE / NEXT", columns.ACTIVE, import_chalk33.default.green);
10422
- displayColumn("\u{1F512} LOCKED", columns.LOCKED, import_chalk33.default.blue);
10423
- displayColumn("\u23F3 PENDING", columns.PENDING, import_chalk33.default.gray);
10424
- 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"));
10425
- 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.`));
10426
10526
  } catch (e) {
10427
- spinner.fail(import_chalk33.default.red(`
10527
+ spinner.fail(import_chalk34.default.red(`
10428
10528
  Failed to fetch roadmap: ${e.message}`));
10429
10529
  }
10430
10530
  });
@@ -10435,15 +10535,15 @@ function displayColumn(title, items, color) {
10435
10535
  ${color.bold(title)}`);
10436
10536
  items.sort((a, b) => a.step_number - b.step_number).forEach((item) => {
10437
10537
  const id = `T-${item.step_number}`.padEnd(8);
10438
- const priority = item.priority === "MVP" ? import_chalk33.default.magenta(" [MVP]") : "";
10439
- 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}`);
10440
10540
  });
10441
10541
  }
10442
10542
 
10443
10543
  // src/commands/council.ts
10444
10544
  init_cjs_shims();
10445
10545
  var import_commander23 = require("commander");
10446
- var import_chalk34 = __toESM(require("chalk"), 1);
10546
+ var import_chalk35 = __toESM(require("chalk"), 1);
10447
10547
  var import_ora16 = __toESM(require("ora"), 1);
10448
10548
  var import_inquirer7 = __toESM(require("inquirer"), 1);
10449
10549
  init_config();
@@ -10455,7 +10555,7 @@ function createCouncilCommand() {
10455
10555
  const apiUrl = getApiUrl();
10456
10556
  const projectId = getProjectId();
10457
10557
  if (!projectId) {
10458
- 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".'));
10459
10559
  return;
10460
10560
  }
10461
10561
  let sessionTopic = topic;
@@ -10467,25 +10567,25 @@ function createCouncilCommand() {
10467
10567
  }]);
10468
10568
  sessionTopic = ans.topic;
10469
10569
  }
10470
- console.log(import_chalk34.default.bold.magenta("\n\u2696\uFE0F CONVENING THE COUNCIL OF SOVEREIGNTY\n"));
10471
- console.log(import_chalk34.default.dim(`Topic: ${sessionTopic}`));
10472
- 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"));
10473
- 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..."));
10474
10574
  await sleep(1500);
10475
- console.log(import_chalk34.default.gray(' "This decision affects our backend scalability. I recommend caution."'));
10476
- 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..."));
10477
10577
  await sleep(1500);
10478
- console.log(import_chalk34.default.gray(` "Similar patterns in other projects led to technical debt. Let's review RLS."`));
10479
- 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..."));
10480
10580
  await sleep(1500);
10481
- console.log(import_chalk34.default.gray(' "Implementation will require updating 3 core services."'));
10482
- console.log(import_chalk34.default.bold.white("\n\u{1F4CB} [FINAL DECISION RECORD]"));
10483
- console.log(import_chalk34.default.white(" Status: Approved with conditions"));
10484
- console.log(import_chalk34.default.white(" Rationale: Value outweighs migration cost. Ensure SEC-SQL-01 compliance."));
10485
- 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"));
10486
- 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)"));
10487
10587
  } catch (e) {
10488
- console.error(import_chalk34.default.red(`
10588
+ console.error(import_chalk35.default.red(`
10489
10589
  Council session aborted: ${e.message}`));
10490
10590
  }
10491
10591
  });
@@ -10529,19 +10629,19 @@ program.hook("preAction", async () => {
10529
10629
  });
10530
10630
  program.on("--help", () => {
10531
10631
  console.log("");
10532
- console.log(import_chalk35.default.bold("Examples:"));
10632
+ console.log(import_chalk36.default.bold("Examples:"));
10533
10633
  console.log("");
10534
- console.log(import_chalk35.default.cyan(" $ rigstate login sk_rigstate_your_api_key"));
10535
- 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"));
10536
10636
  console.log("");
10537
- console.log(import_chalk35.default.cyan(" $ rigstate scan"));
10538
- 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"));
10539
10639
  console.log("");
10540
- console.log(import_chalk35.default.cyan(" $ rigstate scan ./src --project abc123"));
10541
- 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"));
10542
10642
  console.log("");
10543
- console.log(import_chalk35.default.cyan(" $ rigstate scan --json"));
10544
- 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)"));
10545
10645
  console.log("");
10546
10646
  });
10547
10647
  program.parse(process.argv);