@rigstate/cli 0.7.30 → 0.7.31
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 +321 -164
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +325 -168
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/daemon/core.ts +38 -1
- package/src/daemon/harvester.ts +199 -0
package/dist/index.cjs
CHANGED
|
@@ -279,12 +279,12 @@ async function syncProjectRules(projectId, apiKey, apiUrl, dryRun = false) {
|
|
|
279
279
|
}
|
|
280
280
|
const files = syncResponse.data.data.files;
|
|
281
281
|
if (files && Array.isArray(files)) {
|
|
282
|
-
const
|
|
283
|
-
const
|
|
282
|
+
const fs26 = await import("fs/promises");
|
|
283
|
+
const path28 = await import("path");
|
|
284
284
|
for (const file of files) {
|
|
285
|
-
const filePath =
|
|
286
|
-
await
|
|
287
|
-
await
|
|
285
|
+
const filePath = path28.join(process.cwd(), file.path);
|
|
286
|
+
await fs26.mkdir(path28.dirname(filePath), { recursive: true });
|
|
287
|
+
await fs26.writeFile(filePath, file.content, "utf-8");
|
|
288
288
|
}
|
|
289
289
|
console.log(import_chalk3.default.dim(` \u{1F4BE} Wrote ${files.length} rule files to local .cursor/rules/`));
|
|
290
290
|
}
|
|
@@ -1533,10 +1533,10 @@ var require_src2 = __commonJS({
|
|
|
1533
1533
|
var fs_1 = require("fs");
|
|
1534
1534
|
var debug_1 = __importDefault(require_src());
|
|
1535
1535
|
var log = debug_1.default("@kwsites/file-exists");
|
|
1536
|
-
function check(
|
|
1537
|
-
log(`checking %s`,
|
|
1536
|
+
function check(path28, isFile, isDirectory) {
|
|
1537
|
+
log(`checking %s`, path28);
|
|
1538
1538
|
try {
|
|
1539
|
-
const stat = fs_1.statSync(
|
|
1539
|
+
const stat = fs_1.statSync(path28);
|
|
1540
1540
|
if (stat.isFile() && isFile) {
|
|
1541
1541
|
log(`[OK] path represents a file`);
|
|
1542
1542
|
return true;
|
|
@@ -1556,8 +1556,8 @@ var require_src2 = __commonJS({
|
|
|
1556
1556
|
throw e;
|
|
1557
1557
|
}
|
|
1558
1558
|
}
|
|
1559
|
-
function exists2(
|
|
1560
|
-
return check(
|
|
1559
|
+
function exists2(path28, type = exports2.READABLE) {
|
|
1560
|
+
return check(path28, (type & exports2.FILE) > 0, (type & exports2.FOLDER) > 0);
|
|
1561
1561
|
}
|
|
1562
1562
|
exports2.exists = exists2;
|
|
1563
1563
|
exports2.FILE = 1;
|
|
@@ -1627,7 +1627,7 @@ var require_package = __commonJS({
|
|
|
1627
1627
|
"package.json"(exports2, module2) {
|
|
1628
1628
|
module2.exports = {
|
|
1629
1629
|
name: "@rigstate/cli",
|
|
1630
|
-
version: "0.7.
|
|
1630
|
+
version: "0.7.31",
|
|
1631
1631
|
description: "Rigstate CLI - Code audit, sync and supervision tool",
|
|
1632
1632
|
type: "module",
|
|
1633
1633
|
main: "./dist/index.js",
|
|
@@ -1773,8 +1773,8 @@ function createLinkCommand() {
|
|
|
1773
1773
|
process.exit(1);
|
|
1774
1774
|
}
|
|
1775
1775
|
console.log(import_chalk5.default.dim("Fetching your projects..."));
|
|
1776
|
-
const
|
|
1777
|
-
const response = await
|
|
1776
|
+
const axios24 = (await import("axios")).default;
|
|
1777
|
+
const response = await axios24.get(`${apiUrl}/api/v1/projects`, {
|
|
1778
1778
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
1779
1779
|
});
|
|
1780
1780
|
if (!response.data.success || !response.data.data.projects?.length) {
|
|
@@ -1846,9 +1846,9 @@ function createLinkCommand() {
|
|
|
1846
1846
|
});
|
|
1847
1847
|
}
|
|
1848
1848
|
async function hardenGitIgnore(cwd) {
|
|
1849
|
-
const
|
|
1850
|
-
const
|
|
1851
|
-
const ignorePath =
|
|
1849
|
+
const fs26 = await import("fs/promises");
|
|
1850
|
+
const path28 = await import("path");
|
|
1851
|
+
const ignorePath = path28.join(cwd, ".gitignore");
|
|
1852
1852
|
const REQUIRED_IGNORES = [
|
|
1853
1853
|
"# Rigstate - Runtime Artifacts (Do not commit)",
|
|
1854
1854
|
".rigstate/ACTIVE_VIOLATIONS.md",
|
|
@@ -1863,7 +1863,7 @@ async function hardenGitIgnore(cwd) {
|
|
|
1863
1863
|
try {
|
|
1864
1864
|
let content = "";
|
|
1865
1865
|
try {
|
|
1866
|
-
content = await
|
|
1866
|
+
content = await fs26.readFile(ignorePath, "utf-8");
|
|
1867
1867
|
} catch {
|
|
1868
1868
|
content = "";
|
|
1869
1869
|
}
|
|
@@ -1871,7 +1871,7 @@ async function hardenGitIgnore(cwd) {
|
|
|
1871
1871
|
if (missing.length > 0) {
|
|
1872
1872
|
console.log(import_chalk5.default.dim(" Configuring .gitignore for Rigstate safety..."));
|
|
1873
1873
|
const toAppend = "\n\n" + REQUIRED_IGNORES.join("\n") + "\n";
|
|
1874
|
-
await
|
|
1874
|
+
await fs26.writeFile(ignorePath, content + toAppend, "utf-8");
|
|
1875
1875
|
console.log(import_chalk5.default.green(" \u2714 .gitignore updated (Artifacts protected)"));
|
|
1876
1876
|
} else {
|
|
1877
1877
|
console.log(import_chalk5.default.green(" \u2714 .gitignore already hardened"));
|
|
@@ -1881,21 +1881,21 @@ async function hardenGitIgnore(cwd) {
|
|
|
1881
1881
|
}
|
|
1882
1882
|
}
|
|
1883
1883
|
async function installHooks(cwd) {
|
|
1884
|
-
const
|
|
1885
|
-
const
|
|
1884
|
+
const fs26 = await import("fs/promises");
|
|
1885
|
+
const path28 = await import("path");
|
|
1886
1886
|
try {
|
|
1887
|
-
await
|
|
1887
|
+
await fs26.access(path28.join(cwd, ".git"));
|
|
1888
1888
|
} catch {
|
|
1889
1889
|
console.log(import_chalk5.default.dim(" (Not a git repository, skipping hooks)"));
|
|
1890
1890
|
return;
|
|
1891
1891
|
}
|
|
1892
|
-
const hooksDir =
|
|
1892
|
+
const hooksDir = path28.join(cwd, ".husky");
|
|
1893
1893
|
try {
|
|
1894
|
-
const preCommitPath =
|
|
1894
|
+
const preCommitPath = path28.join(cwd, ".git/hooks/pre-commit");
|
|
1895
1895
|
let shouldInstall = false;
|
|
1896
1896
|
try {
|
|
1897
|
-
await
|
|
1898
|
-
const content = await
|
|
1897
|
+
await fs26.access(preCommitPath);
|
|
1898
|
+
const content = await fs26.readFile(preCommitPath, "utf-8");
|
|
1899
1899
|
if (content.includes("rigstate")) {
|
|
1900
1900
|
console.log(import_chalk5.default.green(" \u2714 Git hooks already active"));
|
|
1901
1901
|
} else {
|
|
@@ -1919,12 +1919,12 @@ echo "\u{1F6E1}\uFE0F Running Guardian checks..."
|
|
|
1919
1919
|
rigstate check --staged --strict=critical
|
|
1920
1920
|
exit $?
|
|
1921
1921
|
`;
|
|
1922
|
-
await
|
|
1922
|
+
await fs26.mkdir(path28.dirname(preCommitPath), { recursive: true });
|
|
1923
1923
|
if (await fileExists(preCommitPath)) {
|
|
1924
|
-
const existing = await
|
|
1925
|
-
await
|
|
1924
|
+
const existing = await fs26.readFile(preCommitPath, "utf-8");
|
|
1925
|
+
await fs26.writeFile(preCommitPath, existing + "\n\n" + PRE_COMMIT_SCRIPT2.replace("#!/bin/sh\n", ""), { mode: 493 });
|
|
1926
1926
|
} else {
|
|
1927
|
-
await
|
|
1927
|
+
await fs26.writeFile(preCommitPath, PRE_COMMIT_SCRIPT2, { mode: 493 });
|
|
1928
1928
|
}
|
|
1929
1929
|
console.log(import_chalk5.default.green(" \u2714 Applied Guardian protection (git-hooks)"));
|
|
1930
1930
|
}
|
|
@@ -1932,10 +1932,10 @@ exit $?
|
|
|
1932
1932
|
console.log(import_chalk5.default.dim(" (Skipped hooks: " + e.message + ")"));
|
|
1933
1933
|
}
|
|
1934
1934
|
}
|
|
1935
|
-
async function fileExists(
|
|
1936
|
-
const
|
|
1935
|
+
async function fileExists(path28) {
|
|
1936
|
+
const fs26 = await import("fs/promises");
|
|
1937
1937
|
try {
|
|
1938
|
-
await
|
|
1938
|
+
await fs26.access(path28);
|
|
1939
1939
|
return true;
|
|
1940
1940
|
} catch {
|
|
1941
1941
|
return false;
|
|
@@ -3341,8 +3341,8 @@ init_cjs_shims();
|
|
|
3341
3341
|
var import_commander11 = require("commander");
|
|
3342
3342
|
var import_chalk21 = __toESM(require("chalk"), 1);
|
|
3343
3343
|
var import_ora8 = __toESM(require("ora"), 1);
|
|
3344
|
-
var
|
|
3345
|
-
var
|
|
3344
|
+
var import_promises19 = __toESM(require("fs/promises"), 1);
|
|
3345
|
+
var import_path22 = __toESM(require("path"), 1);
|
|
3346
3346
|
|
|
3347
3347
|
// src/daemon/factory.ts
|
|
3348
3348
|
init_cjs_shims();
|
|
@@ -3350,9 +3350,9 @@ init_cjs_shims();
|
|
|
3350
3350
|
// src/daemon/core.ts
|
|
3351
3351
|
init_cjs_shims();
|
|
3352
3352
|
var import_chalk19 = __toESM(require("chalk"), 1);
|
|
3353
|
-
var
|
|
3354
|
-
var
|
|
3355
|
-
var
|
|
3353
|
+
var fs18 = __toESM(require("fs/promises"), 1);
|
|
3354
|
+
var import_path20 = __toESM(require("path"), 1);
|
|
3355
|
+
var import_events4 = require("events");
|
|
3356
3356
|
|
|
3357
3357
|
// src/daemon/file-watcher.ts
|
|
3358
3358
|
init_cjs_shims();
|
|
@@ -3970,8 +3970,142 @@ ${import_chalk18.default.gray("[Circular or invalid object]")}`;
|
|
|
3970
3970
|
}
|
|
3971
3971
|
};
|
|
3972
3972
|
|
|
3973
|
+
// src/daemon/harvester.ts
|
|
3974
|
+
init_cjs_shims();
|
|
3975
|
+
var import_events3 = require("events");
|
|
3976
|
+
var import_chokidar = __toESM(require("chokidar"), 1);
|
|
3977
|
+
var import_path19 = __toESM(require("path"), 1);
|
|
3978
|
+
var import_promises17 = __toESM(require("fs/promises"), 1);
|
|
3979
|
+
var import_crypto = __toESM(require("crypto"), 1);
|
|
3980
|
+
var import_axios15 = __toESM(require("axios"), 1);
|
|
3981
|
+
var KnowledgeHarvester = class extends import_events3.EventEmitter {
|
|
3982
|
+
watcher = null;
|
|
3983
|
+
config;
|
|
3984
|
+
ruleHashes = /* @__PURE__ */ new Map();
|
|
3985
|
+
isReady = false;
|
|
3986
|
+
processingQueue = /* @__PURE__ */ new Set();
|
|
3987
|
+
debounceTimers = /* @__PURE__ */ new Map();
|
|
3988
|
+
// Ignore list to prevent feedback loops with system rules
|
|
3989
|
+
IGNORED_PREFIXES = ["rigstate-identity", "rigstate-guardian"];
|
|
3990
|
+
constructor(config2) {
|
|
3991
|
+
super();
|
|
3992
|
+
this.config = config2;
|
|
3993
|
+
}
|
|
3994
|
+
async start() {
|
|
3995
|
+
await this.loadHashes();
|
|
3996
|
+
const rulesPath = import_path19.default.join(this.config.watchPath, ".cursor", "rules");
|
|
3997
|
+
const watchPattern = import_path19.default.join(rulesPath, "**", "*.mdc");
|
|
3998
|
+
Logger.debug(`\u{1F33E} Harvester watching: ${watchPattern}`);
|
|
3999
|
+
this.watcher = import_chokidar.default.watch(watchPattern, {
|
|
4000
|
+
persistent: true,
|
|
4001
|
+
ignoreInitial: true,
|
|
4002
|
+
// Don't harvest what's already there on boot
|
|
4003
|
+
awaitWriteFinish: {
|
|
4004
|
+
stabilityThreshold: 2e3,
|
|
4005
|
+
pollInterval: 100
|
|
4006
|
+
}
|
|
4007
|
+
});
|
|
4008
|
+
this.watcher.on("add", (path28) => this.handleFileEvent(path28, "add")).on("change", (path28) => this.handleFileEvent(path28, "change"));
|
|
4009
|
+
this.isReady = true;
|
|
4010
|
+
}
|
|
4011
|
+
async stop() {
|
|
4012
|
+
if (this.watcher) {
|
|
4013
|
+
await this.watcher.close();
|
|
4014
|
+
this.watcher = null;
|
|
4015
|
+
}
|
|
4016
|
+
}
|
|
4017
|
+
async handleFileEvent(filePath, event) {
|
|
4018
|
+
const fileName = import_path19.default.basename(filePath);
|
|
4019
|
+
if (this.IGNORED_PREFIXES.some((prefix) => fileName.startsWith(prefix))) {
|
|
4020
|
+
return;
|
|
4021
|
+
}
|
|
4022
|
+
if (this.debounceTimers.has(filePath)) {
|
|
4023
|
+
clearTimeout(this.debounceTimers.get(filePath));
|
|
4024
|
+
}
|
|
4025
|
+
this.debounceTimers.set(filePath, setTimeout(async () => {
|
|
4026
|
+
this.processFile(filePath);
|
|
4027
|
+
this.debounceTimers.delete(filePath);
|
|
4028
|
+
}, 5e3));
|
|
4029
|
+
}
|
|
4030
|
+
async processFile(filePath) {
|
|
4031
|
+
if (this.processingQueue.has(filePath)) return;
|
|
4032
|
+
this.processingQueue.add(filePath);
|
|
4033
|
+
try {
|
|
4034
|
+
const content = await import_promises17.default.readFile(filePath, "utf-8");
|
|
4035
|
+
const currentHash = this.computeHash(content);
|
|
4036
|
+
if (this.ruleHashes.get(filePath) === currentHash) {
|
|
4037
|
+
Logger.debug(`Skipping ${import_path19.default.basename(filePath)} (unchanged hash)`);
|
|
4038
|
+
return;
|
|
4039
|
+
}
|
|
4040
|
+
if (content.length < 20) {
|
|
4041
|
+
Logger.debug(`Skipping ${import_path19.default.basename(filePath)} (too short)`);
|
|
4042
|
+
return;
|
|
4043
|
+
}
|
|
4044
|
+
await this.submitSignal(filePath, content);
|
|
4045
|
+
this.ruleHashes.set(filePath, currentHash);
|
|
4046
|
+
} catch (error) {
|
|
4047
|
+
Logger.warn(`Harvester failed to process ${import_path19.default.basename(filePath)}: ${error.message}`);
|
|
4048
|
+
} finally {
|
|
4049
|
+
this.processingQueue.delete(filePath);
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4052
|
+
async submitSignal(filePath, content) {
|
|
4053
|
+
const title = import_path19.default.basename(filePath, ".mdc");
|
|
4054
|
+
const relativePath = import_path19.default.relative(process.cwd(), filePath);
|
|
4055
|
+
Logger.info(`\u{1F33E} Harvesting new knowledge: ${title}`);
|
|
4056
|
+
try {
|
|
4057
|
+
const descriptionMatch = content.match(/description:\s*(.*)/);
|
|
4058
|
+
const description = descriptionMatch ? descriptionMatch[1].trim() : "Auto-harvested from IDE interaction";
|
|
4059
|
+
const payload = {
|
|
4060
|
+
project_id: this.config.projectId,
|
|
4061
|
+
title,
|
|
4062
|
+
category: "ARCHITECTURE",
|
|
4063
|
+
// Default
|
|
4064
|
+
severity: "MEDIUM",
|
|
4065
|
+
instruction: content,
|
|
4066
|
+
reasoning: `Harvested from local file: ${relativePath}`,
|
|
4067
|
+
source_type: "IDE_HARVESTER"
|
|
4068
|
+
};
|
|
4069
|
+
const response = await import_axios15.default.post(`${this.config.apiUrl}/api/v1/curator/signals`, payload, {
|
|
4070
|
+
headers: { Authorization: `Bearer ${this.config.apiKey}` }
|
|
4071
|
+
});
|
|
4072
|
+
if (response.data.success) {
|
|
4073
|
+
Logger.info(`\u2705 Signal submitted for review: ${title}`);
|
|
4074
|
+
} else {
|
|
4075
|
+
throw new Error(response.data.error || "Unknown API error");
|
|
4076
|
+
}
|
|
4077
|
+
} catch (error) {
|
|
4078
|
+
if (error.response?.status === 404) {
|
|
4079
|
+
Logger.debug("Curator API not reachable (404). Signal stored locally (mock).");
|
|
4080
|
+
} else {
|
|
4081
|
+
Logger.error(`Failed to submit signal: ${error.message}`);
|
|
4082
|
+
this.ruleHashes.delete(filePath);
|
|
4083
|
+
throw error;
|
|
4084
|
+
}
|
|
4085
|
+
}
|
|
4086
|
+
}
|
|
4087
|
+
async loadHashes() {
|
|
4088
|
+
const rulesPath = import_path19.default.join(this.config.watchPath, ".cursor", "rules");
|
|
4089
|
+
try {
|
|
4090
|
+
await import_promises17.default.mkdir(rulesPath, { recursive: true });
|
|
4091
|
+
const files = await import_promises17.default.readdir(rulesPath);
|
|
4092
|
+
for (const file of files) {
|
|
4093
|
+
if (file.endsWith(".mdc")) {
|
|
4094
|
+
const fullPath = import_path19.default.join(rulesPath, file);
|
|
4095
|
+
const content = await import_promises17.default.readFile(fullPath, "utf-8");
|
|
4096
|
+
this.ruleHashes.set(fullPath, this.computeHash(content));
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
} catch (e) {
|
|
4100
|
+
}
|
|
4101
|
+
}
|
|
4102
|
+
computeHash(content) {
|
|
4103
|
+
return import_crypto.default.createHash("sha256").update(content).digest("hex");
|
|
4104
|
+
}
|
|
4105
|
+
};
|
|
4106
|
+
|
|
3973
4107
|
// src/daemon/core.ts
|
|
3974
|
-
var GuardianDaemon = class extends
|
|
4108
|
+
var GuardianDaemon = class extends import_events4.EventEmitter {
|
|
3975
4109
|
config;
|
|
3976
4110
|
state;
|
|
3977
4111
|
fileWatcher = null;
|
|
@@ -3979,6 +4113,8 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
3979
4113
|
heuristicEngine = null;
|
|
3980
4114
|
interventionProtocol = null;
|
|
3981
4115
|
bridgeListener = null;
|
|
4116
|
+
harvester = null;
|
|
4117
|
+
syncInterval = null;
|
|
3982
4118
|
constructor(config2) {
|
|
3983
4119
|
super();
|
|
3984
4120
|
this.config = config2;
|
|
@@ -4002,13 +4138,24 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4002
4138
|
this.heuristicEngine = createHeuristicEngine();
|
|
4003
4139
|
this.interventionProtocol = createInterventionProtocol();
|
|
4004
4140
|
this.guardianMonitor = createGuardianMonitor(this.config.projectId, this.config.apiUrl, this.config.apiKey);
|
|
4141
|
+
this.harvester = new KnowledgeHarvester({
|
|
4142
|
+
projectId: this.config.projectId,
|
|
4143
|
+
apiUrl: this.config.apiUrl,
|
|
4144
|
+
apiKey: this.config.apiKey,
|
|
4145
|
+
watchPath: process.cwd()
|
|
4146
|
+
});
|
|
4005
4147
|
await this.guardianMonitor.loadRules();
|
|
4006
4148
|
Logger.info(`Loaded ${this.guardianMonitor.getRuleCount()} rules`);
|
|
4007
4149
|
Logger.info("Syncing Brain to IDE (.cursor/rules)...");
|
|
4008
|
-
await
|
|
4150
|
+
await this.runRuleSync();
|
|
4009
4151
|
await this.syncHeuristics();
|
|
4010
4152
|
if (this.config.checkOnChange) {
|
|
4011
4153
|
this.setupFileWatcher();
|
|
4154
|
+
await this.harvester.start();
|
|
4155
|
+
Logger.info("Starting Auto-Sync Poller (5m interval)...");
|
|
4156
|
+
this.syncInterval = setInterval(() => {
|
|
4157
|
+
this.runRuleSync().catch((e) => Logger.error(`Auto-Sync failed: ${e.message}`));
|
|
4158
|
+
}, 5 * 60 * 1e3);
|
|
4012
4159
|
}
|
|
4013
4160
|
if (this.config.bridgeEnabled) {
|
|
4014
4161
|
try {
|
|
@@ -4022,6 +4169,14 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4022
4169
|
await this.updateViolationReport([]);
|
|
4023
4170
|
this.emit("started", this.state);
|
|
4024
4171
|
}
|
|
4172
|
+
async runRuleSync() {
|
|
4173
|
+
try {
|
|
4174
|
+
await syncProjectRules(this.config.projectId, this.config.apiKey, this.config.apiUrl);
|
|
4175
|
+
Logger.debug("Auto-Sync completed successfully");
|
|
4176
|
+
} catch (error) {
|
|
4177
|
+
Logger.warn(`Rule sync hiccup: ${error.message}`);
|
|
4178
|
+
}
|
|
4179
|
+
}
|
|
4025
4180
|
printWelcome() {
|
|
4026
4181
|
console.log(import_chalk19.default.bold.blue("\n\u{1F6E1}\uFE0F Guardian Daemon Starting..."));
|
|
4027
4182
|
console.log(import_chalk19.default.dim(`Project: ${this.config.projectId}`));
|
|
@@ -4042,7 +4197,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4042
4197
|
setupFileWatcher() {
|
|
4043
4198
|
Logger.info("Starting file watcher...");
|
|
4044
4199
|
this.fileWatcher = createFileWatcher(this.config.watchPath);
|
|
4045
|
-
this.fileWatcher.on("change", (
|
|
4200
|
+
this.fileWatcher.on("change", (path28) => this.handleFileChange(path28));
|
|
4046
4201
|
this.fileWatcher.start();
|
|
4047
4202
|
Logger.info("File watcher active");
|
|
4048
4203
|
}
|
|
@@ -4055,7 +4210,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4055
4210
|
}
|
|
4056
4211
|
async getLineCount(filePath) {
|
|
4057
4212
|
try {
|
|
4058
|
-
const content = await
|
|
4213
|
+
const content = await fs18.readFile(filePath, "utf-8");
|
|
4059
4214
|
return content.split("\n").length;
|
|
4060
4215
|
} catch (e) {
|
|
4061
4216
|
return 0;
|
|
@@ -4092,7 +4247,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4092
4247
|
}
|
|
4093
4248
|
}
|
|
4094
4249
|
async updateViolationReport(violations) {
|
|
4095
|
-
const reportPath =
|
|
4250
|
+
const reportPath = import_path20.default.join(process.cwd(), ".rigstate", "ACTIVE_VIOLATIONS.md");
|
|
4096
4251
|
const allViolations = Array.from(this.violationsMap.entries());
|
|
4097
4252
|
const totalCount = allViolations.reduce((acc, [, v]) => acc + v.length, 0);
|
|
4098
4253
|
let content = `# \u{1F6E1}\uFE0F Guardian Status: ${totalCount > 0 ? "\u26A0\uFE0F ATTENTION" : "\u2705 PASS"}
|
|
@@ -4108,7 +4263,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4108
4263
|
} else {
|
|
4109
4264
|
content += "### \u{1F6A8} Active Violations\n\n";
|
|
4110
4265
|
for (const [file, fileViolations] of allViolations) {
|
|
4111
|
-
const relPath =
|
|
4266
|
+
const relPath = import_path20.default.relative(process.cwd(), file);
|
|
4112
4267
|
content += `#### \u{1F4C4} ${relPath}
|
|
4113
4268
|
`;
|
|
4114
4269
|
for (const v of fileViolations) {
|
|
@@ -4120,7 +4275,7 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4120
4275
|
content += "\n---\n*Rigstate Daemon is watching. Fix violations to clear this report.*";
|
|
4121
4276
|
}
|
|
4122
4277
|
try {
|
|
4123
|
-
await
|
|
4278
|
+
await fs18.writeFile(reportPath, content, "utf-8");
|
|
4124
4279
|
} catch (e) {
|
|
4125
4280
|
}
|
|
4126
4281
|
}
|
|
@@ -4157,6 +4312,8 @@ var GuardianDaemon = class extends import_events3.EventEmitter {
|
|
|
4157
4312
|
console.log(import_chalk19.default.dim("\n\u{1F6D1} Stopping Guardian Daemon..."));
|
|
4158
4313
|
if (this.fileWatcher) await this.fileWatcher.stop();
|
|
4159
4314
|
if (this.bridgeListener) await this.bridgeListener.disconnect();
|
|
4315
|
+
if (this.harvester) await this.harvester.stop();
|
|
4316
|
+
if (this.syncInterval) clearInterval(this.syncInterval);
|
|
4160
4317
|
this.state.isRunning = false;
|
|
4161
4318
|
console.log(import_chalk19.default.green("\u2713 Daemon stopped."));
|
|
4162
4319
|
this.emit("stopped", this.state);
|
|
@@ -4198,8 +4355,8 @@ async function createDaemon(options) {
|
|
|
4198
4355
|
// src/utils/service-manager.ts
|
|
4199
4356
|
init_cjs_shims();
|
|
4200
4357
|
var import_chalk20 = __toESM(require("chalk"), 1);
|
|
4201
|
-
var
|
|
4202
|
-
var
|
|
4358
|
+
var import_promises18 = __toESM(require("fs/promises"), 1);
|
|
4359
|
+
var import_path21 = __toESM(require("path"), 1);
|
|
4203
4360
|
var import_child_process3 = require("child_process");
|
|
4204
4361
|
var import_url = require("url");
|
|
4205
4362
|
async function execShellCommand(cmd) {
|
|
@@ -4222,11 +4379,11 @@ async function enableDaemon() {
|
|
|
4222
4379
|
console.error(import_chalk20.default.red("\u274C Could not determine HOME directory."));
|
|
4223
4380
|
return;
|
|
4224
4381
|
}
|
|
4225
|
-
const agentsDir =
|
|
4226
|
-
const logDir =
|
|
4227
|
-
const plistPath =
|
|
4228
|
-
await
|
|
4229
|
-
await
|
|
4382
|
+
const agentsDir = import_path21.default.join(homeDir, "Library/LaunchAgents");
|
|
4383
|
+
const logDir = import_path21.default.join(homeDir, ".rigstate/logs");
|
|
4384
|
+
const plistPath = import_path21.default.join(agentsDir, "com.rigstate.daemon.plist");
|
|
4385
|
+
await import_promises18.default.mkdir(agentsDir, { recursive: true });
|
|
4386
|
+
await import_promises18.default.mkdir(logDir, { recursive: true });
|
|
4230
4387
|
const scriptPath = (0, import_url.fileURLToPath)(importMetaUrl);
|
|
4231
4388
|
const nodePath = process.execPath;
|
|
4232
4389
|
const plistContent = `<?xml version="1.0" encoding="UTF-8"?>
|
|
@@ -4245,9 +4402,9 @@ async function enableDaemon() {
|
|
|
4245
4402
|
<key>WorkingDirectory</key>
|
|
4246
4403
|
<string>${process.cwd()}</string>
|
|
4247
4404
|
<key>StandardOutPath</key>
|
|
4248
|
-
<string>${
|
|
4405
|
+
<string>${import_path21.default.join(logDir, "daemon.out.log")}</string>
|
|
4249
4406
|
<key>StandardErrorPath</key>
|
|
4250
|
-
<string>${
|
|
4407
|
+
<string>${import_path21.default.join(logDir, "daemon.err.log")}</string>
|
|
4251
4408
|
<key>RunAtLoad</key>
|
|
4252
4409
|
<true/>
|
|
4253
4410
|
<key>KeepAlive</key>
|
|
@@ -4260,7 +4417,7 @@ async function enableDaemon() {
|
|
|
4260
4417
|
</dict>
|
|
4261
4418
|
</plist>`;
|
|
4262
4419
|
try {
|
|
4263
|
-
await
|
|
4420
|
+
await import_promises18.default.writeFile(plistPath, plistContent);
|
|
4264
4421
|
console.log(import_chalk20.default.dim(`Created plist at: ${plistPath}`));
|
|
4265
4422
|
try {
|
|
4266
4423
|
await execShellCommand(`launchctl unload ${plistPath}`);
|
|
@@ -4277,10 +4434,10 @@ async function enableDaemon() {
|
|
|
4277
4434
|
async function disableDaemon() {
|
|
4278
4435
|
console.log(import_chalk20.default.bold("\n\u2699\uFE0F Disabling Rigstate Background Service\n"));
|
|
4279
4436
|
const homeDir = process.env.HOME || "";
|
|
4280
|
-
const plistPath =
|
|
4437
|
+
const plistPath = import_path21.default.join(homeDir, "Library/LaunchAgents/com.rigstate.daemon.plist");
|
|
4281
4438
|
try {
|
|
4282
4439
|
await execShellCommand(`launchctl unload ${plistPath}`);
|
|
4283
|
-
await
|
|
4440
|
+
await import_promises18.default.unlink(plistPath);
|
|
4284
4441
|
console.log(import_chalk20.default.green("\u2705 Successfully disabled background daemon."));
|
|
4285
4442
|
} catch (error) {
|
|
4286
4443
|
if (error.code === "ENOENT") {
|
|
@@ -4311,9 +4468,9 @@ function createDaemonCommand() {
|
|
|
4311
4468
|
}
|
|
4312
4469
|
const spinner = (0, import_ora8.default)();
|
|
4313
4470
|
try {
|
|
4314
|
-
const pidPath =
|
|
4471
|
+
const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
|
|
4315
4472
|
try {
|
|
4316
|
-
const content = await
|
|
4473
|
+
const content = await import_promises19.default.readFile(pidPath, "utf-8");
|
|
4317
4474
|
const pid = parseInt(content.trim(), 10);
|
|
4318
4475
|
try {
|
|
4319
4476
|
process.kill(pid, 0);
|
|
@@ -4321,7 +4478,7 @@ function createDaemonCommand() {
|
|
|
4321
4478
|
console.log(import_chalk21.default.dim(` Run "rigstate daemon status" for details or Ctrl+C to stop.
|
|
4322
4479
|
`));
|
|
4323
4480
|
} catch {
|
|
4324
|
-
await
|
|
4481
|
+
await import_promises19.default.unlink(pidPath).catch(() => {
|
|
4325
4482
|
});
|
|
4326
4483
|
}
|
|
4327
4484
|
} catch {
|
|
@@ -4365,14 +4522,14 @@ function createDaemonCommand() {
|
|
|
4365
4522
|
}
|
|
4366
4523
|
async function isRunning() {
|
|
4367
4524
|
try {
|
|
4368
|
-
const pidPath =
|
|
4369
|
-
const content = await
|
|
4525
|
+
const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
|
|
4526
|
+
const content = await import_promises19.default.readFile(pidPath, "utf-8");
|
|
4370
4527
|
const pid = parseInt(content.trim(), 10);
|
|
4371
4528
|
try {
|
|
4372
4529
|
process.kill(pid, 0);
|
|
4373
4530
|
return true;
|
|
4374
4531
|
} catch {
|
|
4375
|
-
await
|
|
4532
|
+
await import_promises19.default.unlink(pidPath);
|
|
4376
4533
|
return false;
|
|
4377
4534
|
}
|
|
4378
4535
|
} catch {
|
|
@@ -4381,25 +4538,25 @@ async function isRunning() {
|
|
|
4381
4538
|
}
|
|
4382
4539
|
async function writePidFile() {
|
|
4383
4540
|
try {
|
|
4384
|
-
const dir =
|
|
4385
|
-
await
|
|
4386
|
-
await
|
|
4541
|
+
const dir = import_path22.default.join(process.cwd(), ".rigstate");
|
|
4542
|
+
await import_promises19.default.mkdir(dir, { recursive: true });
|
|
4543
|
+
await import_promises19.default.writeFile(import_path22.default.join(dir, "daemon.pid"), process.pid.toString());
|
|
4387
4544
|
} catch {
|
|
4388
4545
|
}
|
|
4389
4546
|
}
|
|
4390
4547
|
async function cleanupPidFile() {
|
|
4391
4548
|
try {
|
|
4392
|
-
await
|
|
4393
|
-
await
|
|
4549
|
+
await import_promises19.default.unlink(import_path22.default.join(process.cwd(), PID_FILE));
|
|
4550
|
+
await import_promises19.default.unlink(import_path22.default.join(process.cwd(), STATE_FILE));
|
|
4394
4551
|
} catch {
|
|
4395
4552
|
}
|
|
4396
4553
|
}
|
|
4397
4554
|
async function writeStateFile(state) {
|
|
4398
4555
|
try {
|
|
4399
|
-
const dir =
|
|
4400
|
-
await
|
|
4401
|
-
await
|
|
4402
|
-
|
|
4556
|
+
const dir = import_path22.default.join(process.cwd(), ".rigstate");
|
|
4557
|
+
await import_promises19.default.mkdir(dir, { recursive: true });
|
|
4558
|
+
await import_promises19.default.writeFile(
|
|
4559
|
+
import_path22.default.join(dir, "daemon.state.json"),
|
|
4403
4560
|
JSON.stringify(state, null, 2)
|
|
4404
4561
|
);
|
|
4405
4562
|
} catch {
|
|
@@ -4415,8 +4572,8 @@ async function showStatus() {
|
|
|
4415
4572
|
}
|
|
4416
4573
|
console.log(import_chalk21.default.green("Status: Running"));
|
|
4417
4574
|
try {
|
|
4418
|
-
const statePath =
|
|
4419
|
-
const content = await
|
|
4575
|
+
const statePath = import_path22.default.join(process.cwd(), STATE_FILE);
|
|
4576
|
+
const content = await import_promises19.default.readFile(statePath, "utf-8");
|
|
4420
4577
|
const state = JSON.parse(content);
|
|
4421
4578
|
console.log(import_chalk21.default.dim("\u2500".repeat(40)));
|
|
4422
4579
|
console.log(`Started at: ${state.startedAt || "Unknown"}`);
|
|
@@ -4429,8 +4586,8 @@ async function showStatus() {
|
|
|
4429
4586
|
console.log(import_chalk21.default.dim("(State file not found)"));
|
|
4430
4587
|
}
|
|
4431
4588
|
try {
|
|
4432
|
-
const pidPath =
|
|
4433
|
-
const pid = await
|
|
4589
|
+
const pidPath = import_path22.default.join(process.cwd(), PID_FILE);
|
|
4590
|
+
const pid = await import_promises19.default.readFile(pidPath, "utf-8");
|
|
4434
4591
|
console.log(import_chalk21.default.dim(`PID: ${pid.trim()}`));
|
|
4435
4592
|
} catch {
|
|
4436
4593
|
}
|
|
@@ -4442,7 +4599,7 @@ init_cjs_shims();
|
|
|
4442
4599
|
var import_commander13 = require("commander");
|
|
4443
4600
|
var import_chalk23 = __toESM(require("chalk"), 1);
|
|
4444
4601
|
var import_ora10 = __toESM(require("ora"), 1);
|
|
4445
|
-
var
|
|
4602
|
+
var import_axios17 = __toESM(require("axios"), 1);
|
|
4446
4603
|
var import_inquirer3 = __toESM(require("inquirer"), 1);
|
|
4447
4604
|
init_config();
|
|
4448
4605
|
init_suggest();
|
|
@@ -4452,9 +4609,9 @@ init_cjs_shims();
|
|
|
4452
4609
|
var import_commander12 = require("commander");
|
|
4453
4610
|
var import_chalk22 = __toESM(require("chalk"), 1);
|
|
4454
4611
|
var import_ora9 = __toESM(require("ora"), 1);
|
|
4455
|
-
var
|
|
4456
|
-
var
|
|
4457
|
-
var
|
|
4612
|
+
var import_axios16 = __toESM(require("axios"), 1);
|
|
4613
|
+
var import_promises20 = __toESM(require("fs/promises"), 1);
|
|
4614
|
+
var import_path23 = __toESM(require("path"), 1);
|
|
4458
4615
|
var import_inquirer2 = __toESM(require("inquirer"), 1);
|
|
4459
4616
|
init_config();
|
|
4460
4617
|
function createPlanCommand() {
|
|
@@ -4473,7 +4630,7 @@ async function executePlan(taskId) {
|
|
|
4473
4630
|
let taskDescription = "";
|
|
4474
4631
|
if (!taskId) {
|
|
4475
4632
|
spinner.text = "Fetching actionable tasks...";
|
|
4476
|
-
const response = await
|
|
4633
|
+
const response = await import_axios16.default.get(
|
|
4477
4634
|
`${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
|
|
4478
4635
|
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
4479
4636
|
);
|
|
@@ -4500,7 +4657,7 @@ async function executePlan(taskId) {
|
|
|
4500
4657
|
taskId = `T-${answer.task.step_number}`;
|
|
4501
4658
|
} else {
|
|
4502
4659
|
spinner.text = `Fetching details for ${taskId}...`;
|
|
4503
|
-
const response = await
|
|
4660
|
+
const response = await import_axios16.default.get(
|
|
4504
4661
|
`${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
|
|
4505
4662
|
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
4506
4663
|
);
|
|
@@ -4513,7 +4670,7 @@ async function executePlan(taskId) {
|
|
|
4513
4670
|
taskDescription = task.description;
|
|
4514
4671
|
}
|
|
4515
4672
|
spinner.start("Generating Context for Frank...");
|
|
4516
|
-
const contextPath =
|
|
4673
|
+
const contextPath = import_path23.default.join(process.cwd(), ".rigstate", "CURRENT_CONTEXT.md");
|
|
4517
4674
|
const contextContent = `
|
|
4518
4675
|
# \u{1F3AF} Active Mission: ${taskTitle}
|
|
4519
4676
|
**ID:** ${taskId}
|
|
@@ -4528,10 +4685,10 @@ ${taskDescription}
|
|
|
4528
4685
|
|
|
4529
4686
|
*Generated by Rigstate CLI at ${(/* @__PURE__ */ new Date()).toLocaleString()}*
|
|
4530
4687
|
`;
|
|
4531
|
-
await
|
|
4532
|
-
await
|
|
4533
|
-
const planPath =
|
|
4534
|
-
const planExists = await
|
|
4688
|
+
await import_promises20.default.mkdir(import_path23.default.dirname(contextPath), { recursive: true });
|
|
4689
|
+
await import_promises20.default.writeFile(contextPath, contextContent.trim());
|
|
4690
|
+
const planPath = import_path23.default.join(process.cwd(), "IMPLEMENTATION_PLAN.md");
|
|
4691
|
+
const planExists = await import_promises20.default.stat(planPath).then(() => true).catch(() => false);
|
|
4535
4692
|
if (!planExists) {
|
|
4536
4693
|
const planTemplate = `
|
|
4537
4694
|
# \u{1F4CB} Implementation Plan: ${taskTitle}
|
|
@@ -4550,7 +4707,7 @@ ${taskDescription}
|
|
|
4550
4707
|
## 4. \u{1F680} Execution
|
|
4551
4708
|
[Frank: Log your progress here]
|
|
4552
4709
|
`;
|
|
4553
|
-
await
|
|
4710
|
+
await import_promises20.default.writeFile(planPath, planTemplate.trim());
|
|
4554
4711
|
spinner.succeed(import_chalk22.default.green("Created new IMPLEMENTATION_PLAN.md"));
|
|
4555
4712
|
} else {
|
|
4556
4713
|
spinner.info(import_chalk22.default.yellow("IMPLEMENTATION_PLAN.md already exists. Preserving it."));
|
|
@@ -4597,7 +4754,7 @@ async function listInteractive() {
|
|
|
4597
4754
|
const spinner = (0, import_ora10.default)("Fetching roadmap...").start();
|
|
4598
4755
|
try {
|
|
4599
4756
|
const { projectId, apiKey, apiUrl } = getContext2();
|
|
4600
|
-
const response = await
|
|
4757
|
+
const response = await import_axios17.default.get(
|
|
4601
4758
|
`${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
|
|
4602
4759
|
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
4603
4760
|
);
|
|
@@ -4657,12 +4814,12 @@ async function setTaskStatus(taskId, status) {
|
|
|
4657
4814
|
let realId = taskId;
|
|
4658
4815
|
if (taskId.startsWith("T-") || taskId.length < 10) {
|
|
4659
4816
|
spinner.text = "Resolving Task ID...";
|
|
4660
|
-
const lookup = await
|
|
4817
|
+
const lookup = await import_axios17.default.get(`${apiUrl}/api/v1/roadmap?project_id=${projectId}`, { headers: { Authorization: `Bearer ${apiKey}` } });
|
|
4661
4818
|
const task = lookup.data.data.roadmap.find((t) => `T-${t.step_number}` === taskId || t.step_number.toString() === taskId);
|
|
4662
4819
|
if (!task) throw new Error(`Task ${taskId} not found.`);
|
|
4663
4820
|
realId = task.id;
|
|
4664
4821
|
}
|
|
4665
|
-
await
|
|
4822
|
+
await import_axios17.default.post(
|
|
4666
4823
|
`${apiUrl}/api/v1/roadmap/update-status`,
|
|
4667
4824
|
{ step_id: realId, status, project_id: projectId },
|
|
4668
4825
|
{ headers: { "Authorization": `Bearer ${apiKey}` } }
|
|
@@ -4704,12 +4861,12 @@ init_cjs_shims();
|
|
|
4704
4861
|
var import_commander14 = require("commander");
|
|
4705
4862
|
var import_chalk24 = __toESM(require("chalk"), 1);
|
|
4706
4863
|
var import_ora11 = __toESM(require("ora"), 1);
|
|
4707
|
-
var
|
|
4708
|
-
var
|
|
4709
|
-
var
|
|
4864
|
+
var import_chokidar2 = __toESM(require("chokidar"), 1);
|
|
4865
|
+
var import_promises21 = __toESM(require("fs/promises"), 1);
|
|
4866
|
+
var import_path24 = __toESM(require("path"), 1);
|
|
4710
4867
|
var import_child_process4 = require("child_process");
|
|
4711
4868
|
init_config();
|
|
4712
|
-
var
|
|
4869
|
+
var import_axios18 = __toESM(require("axios"), 1);
|
|
4713
4870
|
function createWatchCommand() {
|
|
4714
4871
|
const watch2 = new import_commander14.Command("watch");
|
|
4715
4872
|
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) => {
|
|
@@ -4727,8 +4884,8 @@ function createWatchCommand() {
|
|
|
4727
4884
|
projectId = getProjectId();
|
|
4728
4885
|
if (!projectId) {
|
|
4729
4886
|
try {
|
|
4730
|
-
const manifestPath =
|
|
4731
|
-
const content = await
|
|
4887
|
+
const manifestPath = import_path24.default.join(process.cwd(), ".rigstate");
|
|
4888
|
+
const content = await import_promises21.default.readFile(manifestPath, "utf-8");
|
|
4732
4889
|
const manifest = JSON.parse(content);
|
|
4733
4890
|
projectId = manifest.project_id;
|
|
4734
4891
|
} catch (e) {
|
|
@@ -4750,7 +4907,7 @@ function createWatchCommand() {
|
|
|
4750
4907
|
console.log("");
|
|
4751
4908
|
const fetchActiveTask = async () => {
|
|
4752
4909
|
try {
|
|
4753
|
-
const response = await
|
|
4910
|
+
const response = await import_axios18.default.get(`${apiUrl}/api/v1/roadmap`, {
|
|
4754
4911
|
params: { project_id: projectId },
|
|
4755
4912
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4756
4913
|
});
|
|
@@ -4774,17 +4931,17 @@ function createWatchCommand() {
|
|
|
4774
4931
|
};
|
|
4775
4932
|
const checkCriteria = async (criteria) => {
|
|
4776
4933
|
try {
|
|
4777
|
-
const fullPath =
|
|
4934
|
+
const fullPath = import_path24.default.resolve(process.cwd(), criteria.path);
|
|
4778
4935
|
switch (criteria.type) {
|
|
4779
4936
|
case "file_exists":
|
|
4780
|
-
await
|
|
4937
|
+
await import_promises21.default.access(fullPath);
|
|
4781
4938
|
return true;
|
|
4782
4939
|
case "file_content":
|
|
4783
|
-
const content = await
|
|
4940
|
+
const content = await import_promises21.default.readFile(fullPath, "utf-8");
|
|
4784
4941
|
return content.length > 0;
|
|
4785
4942
|
case "content_match":
|
|
4786
4943
|
if (!criteria.match) return false;
|
|
4787
|
-
const fileContent = await
|
|
4944
|
+
const fileContent = await import_promises21.default.readFile(fullPath, "utf-8");
|
|
4788
4945
|
return fileContent.includes(criteria.match);
|
|
4789
4946
|
default:
|
|
4790
4947
|
return false;
|
|
@@ -4806,7 +4963,7 @@ function createWatchCommand() {
|
|
|
4806
4963
|
return;
|
|
4807
4964
|
}
|
|
4808
4965
|
}
|
|
4809
|
-
await
|
|
4966
|
+
await import_axios18.default.post(`${apiUrl}/api/v1/roadmap/update-status`, {
|
|
4810
4967
|
project_id: projectId,
|
|
4811
4968
|
chunk_id: taskId,
|
|
4812
4969
|
status: "COMPLETED"
|
|
@@ -4881,7 +5038,7 @@ function createWatchCommand() {
|
|
|
4881
5038
|
isProcessing = false;
|
|
4882
5039
|
};
|
|
4883
5040
|
await processActiveTask();
|
|
4884
|
-
const watcher =
|
|
5041
|
+
const watcher = import_chokidar2.default.watch(".", {
|
|
4885
5042
|
ignored: [
|
|
4886
5043
|
/(^|[\/\\])\../,
|
|
4887
5044
|
// dotfiles
|
|
@@ -4916,10 +5073,10 @@ var import_commander15 = require("commander");
|
|
|
4916
5073
|
var import_chalk25 = __toESM(require("chalk"), 1);
|
|
4917
5074
|
var import_ora12 = __toESM(require("ora"), 1);
|
|
4918
5075
|
init_config();
|
|
4919
|
-
var
|
|
5076
|
+
var import_axios19 = __toESM(require("axios"), 1);
|
|
4920
5077
|
var import_child_process5 = require("child_process");
|
|
4921
|
-
var
|
|
4922
|
-
var
|
|
5078
|
+
var import_promises22 = __toESM(require("fs/promises"), 1);
|
|
5079
|
+
var import_path25 = __toESM(require("path"), 1);
|
|
4923
5080
|
function createFocusCommand() {
|
|
4924
5081
|
const focus = new import_commander15.Command("focus");
|
|
4925
5082
|
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) => {
|
|
@@ -4935,8 +5092,8 @@ function createFocusCommand() {
|
|
|
4935
5092
|
projectId = getProjectId();
|
|
4936
5093
|
if (!projectId) {
|
|
4937
5094
|
try {
|
|
4938
|
-
const manifestPath =
|
|
4939
|
-
const content = await
|
|
5095
|
+
const manifestPath = import_path25.default.join(process.cwd(), ".rigstate");
|
|
5096
|
+
const content = await import_promises22.default.readFile(manifestPath, "utf-8");
|
|
4940
5097
|
const manifest = JSON.parse(content);
|
|
4941
5098
|
projectId = manifest.project_id;
|
|
4942
5099
|
} catch (e) {
|
|
@@ -4948,7 +5105,7 @@ function createFocusCommand() {
|
|
|
4948
5105
|
}
|
|
4949
5106
|
const apiUrl = getApiUrl();
|
|
4950
5107
|
try {
|
|
4951
|
-
const response = await
|
|
5108
|
+
const response = await import_axios19.default.get(`${apiUrl}/api/v1/roadmap`, {
|
|
4952
5109
|
params: { project_id: projectId },
|
|
4953
5110
|
headers: { Authorization: `Bearer ${apiKey}` }
|
|
4954
5111
|
});
|
|
@@ -5090,22 +5247,22 @@ init_cjs_shims();
|
|
|
5090
5247
|
var import_commander17 = require("commander");
|
|
5091
5248
|
var import_chalk27 = __toESM(require("chalk"), 1);
|
|
5092
5249
|
var import_child_process6 = require("child_process");
|
|
5093
|
-
var
|
|
5250
|
+
var import_path26 = __toESM(require("path"), 1);
|
|
5094
5251
|
var import_fs = __toESM(require("fs"), 1);
|
|
5095
5252
|
var import_url2 = require("url");
|
|
5096
5253
|
init_config();
|
|
5097
5254
|
var __filename2 = (0, import_url2.fileURLToPath)(importMetaUrl);
|
|
5098
|
-
var __dirname =
|
|
5255
|
+
var __dirname = import_path26.default.dirname(__filename2);
|
|
5099
5256
|
function createMcpCommand() {
|
|
5100
5257
|
const mcp = new import_commander17.Command("mcp");
|
|
5101
5258
|
mcp.description("Run the Rigstate MCP server for AI editors").action(async () => {
|
|
5102
5259
|
const possiblePaths = [
|
|
5103
5260
|
// From packages/cli -> packages/mcp (sibling package)
|
|
5104
|
-
|
|
5261
|
+
import_path26.default.resolve(__dirname, "../../mcp/dist/index.js"),
|
|
5105
5262
|
// If installed globally or via npm
|
|
5106
|
-
|
|
5263
|
+
import_path26.default.resolve(__dirname, "../../../mcp/dist/index.js"),
|
|
5107
5264
|
// Development path from packages/cli/dist
|
|
5108
|
-
|
|
5265
|
+
import_path26.default.resolve(__dirname, "../../../packages/mcp/dist/index.js")
|
|
5109
5266
|
];
|
|
5110
5267
|
let serverPath = "";
|
|
5111
5268
|
for (const p of possiblePaths) {
|
|
@@ -5161,12 +5318,12 @@ var import_chalk29 = __toESM(require("chalk"), 1);
|
|
|
5161
5318
|
|
|
5162
5319
|
// src/nexus/dispatcher.ts
|
|
5163
5320
|
init_cjs_shims();
|
|
5164
|
-
var
|
|
5321
|
+
var import_events5 = __toESM(require("events"), 1);
|
|
5165
5322
|
var import_uuid = require("uuid");
|
|
5166
5323
|
|
|
5167
5324
|
// src/hive/gateway.ts
|
|
5168
5325
|
init_cjs_shims();
|
|
5169
|
-
var
|
|
5326
|
+
var import_axios20 = __toESM(require("axios"), 1);
|
|
5170
5327
|
|
|
5171
5328
|
// src/hive/scrubber.ts
|
|
5172
5329
|
init_cjs_shims();
|
|
@@ -5237,7 +5394,7 @@ var HiveGateway = class {
|
|
|
5237
5394
|
if (!this.enabled) {
|
|
5238
5395
|
console.log(import_chalk28.default.dim("\u26A0\uFE0F Hive Gateway disabled (No Token provided). Running in localized mode."));
|
|
5239
5396
|
}
|
|
5240
|
-
this.client =
|
|
5397
|
+
this.client = import_axios20.default.create({
|
|
5241
5398
|
baseURL: baseUrl,
|
|
5242
5399
|
headers: {
|
|
5243
5400
|
"Authorization": `Bearer ${token}`,
|
|
@@ -5278,7 +5435,7 @@ var HiveGateway = class {
|
|
|
5278
5435
|
};
|
|
5279
5436
|
|
|
5280
5437
|
// src/nexus/dispatcher.ts
|
|
5281
|
-
var NexusDispatcher = class extends
|
|
5438
|
+
var NexusDispatcher = class extends import_events5.default {
|
|
5282
5439
|
context;
|
|
5283
5440
|
orderQueue = [];
|
|
5284
5441
|
orderHistory = [];
|
|
@@ -5431,7 +5588,7 @@ var import_commander19 = require("commander");
|
|
|
5431
5588
|
var import_chalk30 = __toESM(require("chalk"), 1);
|
|
5432
5589
|
init_governance();
|
|
5433
5590
|
init_config();
|
|
5434
|
-
var
|
|
5591
|
+
var import_axios21 = __toESM(require("axios"), 1);
|
|
5435
5592
|
function createOverrideCommand() {
|
|
5436
5593
|
const override = new import_commander19.Command("override");
|
|
5437
5594
|
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) => {
|
|
@@ -5454,7 +5611,7 @@ function createOverrideCommand() {
|
|
|
5454
5611
|
if (projectId) {
|
|
5455
5612
|
const apiUrl = getApiUrl();
|
|
5456
5613
|
const apiKey = getApiKey();
|
|
5457
|
-
await
|
|
5614
|
+
await import_axios21.default.post(`${apiUrl}/api/v1/execution-logs`, {
|
|
5458
5615
|
project_id: projectId,
|
|
5459
5616
|
task_id: "OVERRIDE-" + Date.now(),
|
|
5460
5617
|
task_title: `Governance Override: ${violationId}`,
|
|
@@ -5482,7 +5639,7 @@ init_cjs_shims();
|
|
|
5482
5639
|
var import_commander20 = require("commander");
|
|
5483
5640
|
var import_chalk31 = __toESM(require("chalk"), 1);
|
|
5484
5641
|
var import_ora13 = __toESM(require("ora"), 1);
|
|
5485
|
-
var
|
|
5642
|
+
var import_axios22 = __toESM(require("axios"), 1);
|
|
5486
5643
|
var import_inquirer5 = __toESM(require("inquirer"), 1);
|
|
5487
5644
|
init_config();
|
|
5488
5645
|
function createIdeaCommand() {
|
|
@@ -5517,7 +5674,7 @@ function createIdeaCommand() {
|
|
|
5517
5674
|
if (tags.length === 0) {
|
|
5518
5675
|
}
|
|
5519
5676
|
const spinner = (0, import_ora13.default)("Securing idea in the Lab...").start();
|
|
5520
|
-
const response = await
|
|
5677
|
+
const response = await import_axios22.default.post(
|
|
5521
5678
|
`${apiUrl}/api/v1/ideas`,
|
|
5522
5679
|
{
|
|
5523
5680
|
project_id: projectId,
|
|
@@ -5547,8 +5704,8 @@ var import_commander21 = require("commander");
|
|
|
5547
5704
|
var import_chalk32 = __toESM(require("chalk"), 1);
|
|
5548
5705
|
var import_ora14 = __toESM(require("ora"), 1);
|
|
5549
5706
|
var import_inquirer6 = __toESM(require("inquirer"), 1);
|
|
5550
|
-
var
|
|
5551
|
-
var
|
|
5707
|
+
var import_promises23 = __toESM(require("fs/promises"), 1);
|
|
5708
|
+
var import_path27 = __toESM(require("path"), 1);
|
|
5552
5709
|
init_config();
|
|
5553
5710
|
|
|
5554
5711
|
// ../../node_modules/simple-git/dist/esm/index.js
|
|
@@ -5589,8 +5746,8 @@ function pathspec(...paths) {
|
|
|
5589
5746
|
cache.set(key, paths);
|
|
5590
5747
|
return key;
|
|
5591
5748
|
}
|
|
5592
|
-
function isPathSpec(
|
|
5593
|
-
return
|
|
5749
|
+
function isPathSpec(path28) {
|
|
5750
|
+
return path28 instanceof String && cache.has(path28);
|
|
5594
5751
|
}
|
|
5595
5752
|
function toPaths(pathSpec) {
|
|
5596
5753
|
return cache.get(pathSpec) || [];
|
|
@@ -5679,8 +5836,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
5679
5836
|
function forEachLineWithContent(input, callback) {
|
|
5680
5837
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
5681
5838
|
}
|
|
5682
|
-
function folderExists(
|
|
5683
|
-
return (0, import_file_exists.exists)(
|
|
5839
|
+
function folderExists(path28) {
|
|
5840
|
+
return (0, import_file_exists.exists)(path28, import_file_exists.FOLDER);
|
|
5684
5841
|
}
|
|
5685
5842
|
function append(target, item) {
|
|
5686
5843
|
if (Array.isArray(target)) {
|
|
@@ -6084,8 +6241,8 @@ function checkIsRepoRootTask() {
|
|
|
6084
6241
|
commands,
|
|
6085
6242
|
format: "utf-8",
|
|
6086
6243
|
onError,
|
|
6087
|
-
parser(
|
|
6088
|
-
return /^\.(git)?$/.test(
|
|
6244
|
+
parser(path28) {
|
|
6245
|
+
return /^\.(git)?$/.test(path28.trim());
|
|
6089
6246
|
}
|
|
6090
6247
|
};
|
|
6091
6248
|
}
|
|
@@ -6519,11 +6676,11 @@ function parseGrep(grep) {
|
|
|
6519
6676
|
const paths = /* @__PURE__ */ new Set();
|
|
6520
6677
|
const results = {};
|
|
6521
6678
|
forEachLineWithContent(grep, (input) => {
|
|
6522
|
-
const [
|
|
6523
|
-
paths.add(
|
|
6524
|
-
(results[
|
|
6679
|
+
const [path28, line, preview] = input.split(NULL);
|
|
6680
|
+
paths.add(path28);
|
|
6681
|
+
(results[path28] = results[path28] || []).push({
|
|
6525
6682
|
line: asNumber(line),
|
|
6526
|
-
path:
|
|
6683
|
+
path: path28,
|
|
6527
6684
|
preview
|
|
6528
6685
|
});
|
|
6529
6686
|
});
|
|
@@ -7288,14 +7445,14 @@ var init_hash_object = __esm2({
|
|
|
7288
7445
|
init_task();
|
|
7289
7446
|
}
|
|
7290
7447
|
});
|
|
7291
|
-
function parseInit(bare,
|
|
7448
|
+
function parseInit(bare, path28, text) {
|
|
7292
7449
|
const response = String(text).trim();
|
|
7293
7450
|
let result;
|
|
7294
7451
|
if (result = initResponseRegex.exec(response)) {
|
|
7295
|
-
return new InitSummary(bare,
|
|
7452
|
+
return new InitSummary(bare, path28, false, result[1]);
|
|
7296
7453
|
}
|
|
7297
7454
|
if (result = reInitResponseRegex.exec(response)) {
|
|
7298
|
-
return new InitSummary(bare,
|
|
7455
|
+
return new InitSummary(bare, path28, true, result[1]);
|
|
7299
7456
|
}
|
|
7300
7457
|
let gitDir = "";
|
|
7301
7458
|
const tokens = response.split(" ");
|
|
@@ -7306,7 +7463,7 @@ function parseInit(bare, path27, text) {
|
|
|
7306
7463
|
break;
|
|
7307
7464
|
}
|
|
7308
7465
|
}
|
|
7309
|
-
return new InitSummary(bare,
|
|
7466
|
+
return new InitSummary(bare, path28, /^re/i.test(response), gitDir);
|
|
7310
7467
|
}
|
|
7311
7468
|
var InitSummary;
|
|
7312
7469
|
var initResponseRegex;
|
|
@@ -7315,9 +7472,9 @@ var init_InitSummary = __esm2({
|
|
|
7315
7472
|
"src/lib/responses/InitSummary.ts"() {
|
|
7316
7473
|
"use strict";
|
|
7317
7474
|
InitSummary = class {
|
|
7318
|
-
constructor(bare,
|
|
7475
|
+
constructor(bare, path28, existing, gitDir) {
|
|
7319
7476
|
this.bare = bare;
|
|
7320
|
-
this.path =
|
|
7477
|
+
this.path = path28;
|
|
7321
7478
|
this.existing = existing;
|
|
7322
7479
|
this.gitDir = gitDir;
|
|
7323
7480
|
}
|
|
@@ -7329,7 +7486,7 @@ var init_InitSummary = __esm2({
|
|
|
7329
7486
|
function hasBareCommand(command) {
|
|
7330
7487
|
return command.includes(bareCommand);
|
|
7331
7488
|
}
|
|
7332
|
-
function initTask(bare = false,
|
|
7489
|
+
function initTask(bare = false, path28, customArgs) {
|
|
7333
7490
|
const commands = ["init", ...customArgs];
|
|
7334
7491
|
if (bare && !hasBareCommand(commands)) {
|
|
7335
7492
|
commands.splice(1, 0, bareCommand);
|
|
@@ -7338,7 +7495,7 @@ function initTask(bare = false, path27, customArgs) {
|
|
|
7338
7495
|
commands,
|
|
7339
7496
|
format: "utf-8",
|
|
7340
7497
|
parser(text) {
|
|
7341
|
-
return parseInit(commands.includes("--bare"),
|
|
7498
|
+
return parseInit(commands.includes("--bare"), path28, text);
|
|
7342
7499
|
}
|
|
7343
7500
|
};
|
|
7344
7501
|
}
|
|
@@ -8154,12 +8311,12 @@ var init_FileStatusSummary = __esm2({
|
|
|
8154
8311
|
"use strict";
|
|
8155
8312
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
8156
8313
|
FileStatusSummary = class {
|
|
8157
|
-
constructor(
|
|
8158
|
-
this.path =
|
|
8314
|
+
constructor(path28, index, working_dir) {
|
|
8315
|
+
this.path = path28;
|
|
8159
8316
|
this.index = index;
|
|
8160
8317
|
this.working_dir = working_dir;
|
|
8161
8318
|
if (index === "R" || working_dir === "R") {
|
|
8162
|
-
const detail = fromPathRegex.exec(
|
|
8319
|
+
const detail = fromPathRegex.exec(path28) || [null, path28, path28];
|
|
8163
8320
|
this.from = detail[2] || "";
|
|
8164
8321
|
this.path = detail[1] || "";
|
|
8165
8322
|
}
|
|
@@ -8190,14 +8347,14 @@ function splitLine(result, lineStr) {
|
|
|
8190
8347
|
default:
|
|
8191
8348
|
return;
|
|
8192
8349
|
}
|
|
8193
|
-
function data(index, workingDir,
|
|
8350
|
+
function data(index, workingDir, path28) {
|
|
8194
8351
|
const raw = `${index}${workingDir}`;
|
|
8195
8352
|
const handler = parsers6.get(raw);
|
|
8196
8353
|
if (handler) {
|
|
8197
|
-
handler(result,
|
|
8354
|
+
handler(result, path28);
|
|
8198
8355
|
}
|
|
8199
8356
|
if (raw !== "##" && raw !== "!!") {
|
|
8200
|
-
result.files.push(new FileStatusSummary(
|
|
8357
|
+
result.files.push(new FileStatusSummary(path28, index, workingDir));
|
|
8201
8358
|
}
|
|
8202
8359
|
}
|
|
8203
8360
|
}
|
|
@@ -8510,9 +8667,9 @@ var init_simple_git_api = __esm2({
|
|
|
8510
8667
|
next
|
|
8511
8668
|
);
|
|
8512
8669
|
}
|
|
8513
|
-
hashObject(
|
|
8670
|
+
hashObject(path28, write) {
|
|
8514
8671
|
return this._runTask(
|
|
8515
|
-
hashObjectTask(
|
|
8672
|
+
hashObjectTask(path28, write === true),
|
|
8516
8673
|
trailingFunctionArgument(arguments)
|
|
8517
8674
|
);
|
|
8518
8675
|
}
|
|
@@ -8865,8 +9022,8 @@ var init_branch = __esm2({
|
|
|
8865
9022
|
}
|
|
8866
9023
|
});
|
|
8867
9024
|
function toPath(input) {
|
|
8868
|
-
const
|
|
8869
|
-
return
|
|
9025
|
+
const path28 = input.trim().replace(/^["']|["']$/g, "");
|
|
9026
|
+
return path28 && (0, import_node_path.normalize)(path28);
|
|
8870
9027
|
}
|
|
8871
9028
|
var parseCheckIgnore;
|
|
8872
9029
|
var init_CheckIgnore = __esm2({
|
|
@@ -9180,8 +9337,8 @@ __export2(sub_module_exports, {
|
|
|
9180
9337
|
subModuleTask: () => subModuleTask,
|
|
9181
9338
|
updateSubModuleTask: () => updateSubModuleTask
|
|
9182
9339
|
});
|
|
9183
|
-
function addSubModuleTask(repo,
|
|
9184
|
-
return subModuleTask(["add", repo,
|
|
9340
|
+
function addSubModuleTask(repo, path28) {
|
|
9341
|
+
return subModuleTask(["add", repo, path28]);
|
|
9185
9342
|
}
|
|
9186
9343
|
function initSubModuleTask(customArgs) {
|
|
9187
9344
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -9511,8 +9668,8 @@ var require_git = __commonJS2({
|
|
|
9511
9668
|
}
|
|
9512
9669
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
9513
9670
|
};
|
|
9514
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
9515
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
9671
|
+
Git2.prototype.submoduleAdd = function(repo, path28, then) {
|
|
9672
|
+
return this._runTask(addSubModuleTask2(repo, path28), trailingFunctionArgument2(arguments));
|
|
9516
9673
|
};
|
|
9517
9674
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
9518
9675
|
return this._runTask(
|
|
@@ -10112,8 +10269,8 @@ function createReleaseCommand() {
|
|
|
10112
10269
|
return;
|
|
10113
10270
|
}
|
|
10114
10271
|
spinner.text = "Scanning completed tasks...";
|
|
10115
|
-
const pkgPath =
|
|
10116
|
-
const pkgContent = await
|
|
10272
|
+
const pkgPath = import_path27.default.resolve(process.cwd(), "package.json");
|
|
10273
|
+
const pkgContent = await import_promises23.default.readFile(pkgPath, "utf-8");
|
|
10117
10274
|
const pkg2 = JSON.parse(pkgContent);
|
|
10118
10275
|
const currentVersion = pkg2.version;
|
|
10119
10276
|
const [major, minor, patch] = currentVersion.split(".").map(Number);
|
|
@@ -10133,17 +10290,17 @@ function createReleaseCommand() {
|
|
|
10133
10290
|
return;
|
|
10134
10291
|
}
|
|
10135
10292
|
pkg2.version = newVersion;
|
|
10136
|
-
await
|
|
10137
|
-
const changelogPath =
|
|
10293
|
+
await import_promises23.default.writeFile(pkgPath, JSON.stringify(pkg2, null, 4));
|
|
10294
|
+
const changelogPath = import_path27.default.resolve(process.cwd(), "CHANGELOG.md");
|
|
10138
10295
|
const date = (/* @__PURE__ */ new Date()).toISOString().split("T")[0];
|
|
10139
10296
|
const entry = `
|
|
10140
10297
|
## [${newVersion}] - ${date}
|
|
10141
10298
|
- Automated release via Rigstate.
|
|
10142
10299
|
`;
|
|
10143
10300
|
try {
|
|
10144
|
-
await
|
|
10301
|
+
await import_promises23.default.appendFile(changelogPath, entry);
|
|
10145
10302
|
} catch {
|
|
10146
|
-
await
|
|
10303
|
+
await import_promises23.default.writeFile(changelogPath, "# Changelog\n" + entry);
|
|
10147
10304
|
}
|
|
10148
10305
|
spinner.start("Tagging and pushing...");
|
|
10149
10306
|
await git.add(["package.json", "CHANGELOG.md"]);
|
|
@@ -10170,7 +10327,7 @@ init_cjs_shims();
|
|
|
10170
10327
|
var import_commander22 = require("commander");
|
|
10171
10328
|
var import_chalk33 = __toESM(require("chalk"), 1);
|
|
10172
10329
|
var import_ora15 = __toESM(require("ora"), 1);
|
|
10173
|
-
var
|
|
10330
|
+
var import_axios23 = __toESM(require("axios"), 1);
|
|
10174
10331
|
init_config();
|
|
10175
10332
|
function createRoadmapCommand() {
|
|
10176
10333
|
return new import_commander22.Command("roadmap").alias("tactical").description("View project roadmap and task status (Tactical View)").action(async () => {
|
|
@@ -10183,7 +10340,7 @@ function createRoadmapCommand() {
|
|
|
10183
10340
|
spinner.fail(import_chalk33.default.red('Project context missing. Run "rigstate link".'));
|
|
10184
10341
|
return;
|
|
10185
10342
|
}
|
|
10186
|
-
const response = await
|
|
10343
|
+
const response = await import_axios23.default.get(
|
|
10187
10344
|
`${apiUrl}/api/v1/roadmap?project_id=${projectId}`,
|
|
10188
10345
|
{ headers: { Authorization: `Bearer ${apiKey}` } }
|
|
10189
10346
|
);
|