gnosys 4.0.0 → 4.1.0
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/README.md +102 -920
- package/dist/cli.js +27 -13
- package/dist/cli.js.map +1 -1
- package/dist/lib/projectIdentity.d.ts.map +1 -1
- package/dist/lib/projectIdentity.js +8 -1
- package/dist/lib/projectIdentity.js.map +1 -1
- package/dist/lib/rulesGen.d.ts +11 -0
- package/dist/lib/rulesGen.d.ts.map +1 -1
- package/dist/lib/rulesGen.js +127 -11
- package/dist/lib/rulesGen.js.map +1 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -28,7 +28,7 @@ import { GnosysDB } from "./lib/db.js";
|
|
|
28
28
|
import { migrate, formatMigrationReport } from "./lib/migrate.js";
|
|
29
29
|
import { createProjectIdentity, readProjectIdentity, findProjectIdentity } from "./lib/projectIdentity.js";
|
|
30
30
|
import { setPreference, getPreference, getAllPreferences, deletePreference } from "./lib/preferences.js";
|
|
31
|
-
import {
|
|
31
|
+
import { syncToTarget } from "./lib/rulesGen.js";
|
|
32
32
|
// Load API keys from ~/.config/gnosys/.env (same as MCP server)
|
|
33
33
|
// IMPORTANT: We use dotenv.parse() instead of dotenv.config() because
|
|
34
34
|
// dotenv v17+ writes injection notices to stdout, which corrupts
|
|
@@ -2697,10 +2697,13 @@ prefCmd
|
|
|
2697
2697
|
// ─── gnosys sync ─────────────────────────────────────────────────────────
|
|
2698
2698
|
program
|
|
2699
2699
|
.command("sync")
|
|
2700
|
-
.description("Regenerate agent rules
|
|
2700
|
+
.description("Regenerate agent rules files from user preferences and project conventions. Injects GNOSYS:START/GNOSYS:END block.")
|
|
2701
2701
|
.option("-d, --directory <dir>", "Project directory (default: cwd)")
|
|
2702
|
+
.option("-t, --target <target>", "Target: claude, cursor, codex, all, or global (default: auto-detect)")
|
|
2703
|
+
.option("--global", "Sync to global ~/.claude/CLAUDE.md")
|
|
2702
2704
|
.action(async (opts) => {
|
|
2703
2705
|
const projectDir = opts.directory ? path.resolve(opts.directory) : process.cwd();
|
|
2706
|
+
const target = opts.global ? "global" : (opts.target || null);
|
|
2704
2707
|
let centralDb = null;
|
|
2705
2708
|
try {
|
|
2706
2709
|
centralDb = GnosysDB.openCentral();
|
|
@@ -2708,26 +2711,37 @@ program
|
|
|
2708
2711
|
console.error("Central DB not available (better-sqlite3 missing).");
|
|
2709
2712
|
process.exit(1);
|
|
2710
2713
|
}
|
|
2714
|
+
// For --global, we don't need project identity
|
|
2715
|
+
if (target === "global") {
|
|
2716
|
+
const results = await syncToTarget(centralDb, projectDir, "global", null);
|
|
2717
|
+
for (const result of results) {
|
|
2718
|
+
const action = result.created ? "Created" : "Updated";
|
|
2719
|
+
console.log(`${action} global rules: ${result.filePath}`);
|
|
2720
|
+
console.log(` Preferences injected: ${result.prefCount}`);
|
|
2721
|
+
}
|
|
2722
|
+
console.log(`\nContent is inside <!-- GNOSYS:START --> / <!-- GNOSYS:END --> markers.`);
|
|
2723
|
+
console.log(`User content outside these markers is preserved.`);
|
|
2724
|
+
return;
|
|
2725
|
+
}
|
|
2711
2726
|
// Read project identity
|
|
2712
2727
|
const identity = await readProjectIdentity(projectDir);
|
|
2713
2728
|
if (!identity) {
|
|
2714
2729
|
console.error("No project identity found. Run 'gnosys init' first.");
|
|
2715
2730
|
process.exit(1);
|
|
2716
2731
|
}
|
|
2717
|
-
|
|
2718
|
-
|
|
2719
|
-
|
|
2732
|
+
// Use explicit target, or fall back to auto-detected, or "all"
|
|
2733
|
+
const resolvedTarget = target || identity.agentRulesTarget || "all";
|
|
2734
|
+
const results = await syncToTarget(centralDb, projectDir, resolvedTarget, identity.projectId);
|
|
2735
|
+
if (results.length === 0) {
|
|
2736
|
+
console.error("No targets found. Create a CLAUDE.md, .cursor/, or .codex/ directory first.");
|
|
2720
2737
|
process.exit(1);
|
|
2721
2738
|
}
|
|
2722
|
-
const result
|
|
2723
|
-
|
|
2724
|
-
console.
|
|
2725
|
-
|
|
2739
|
+
for (const result of results) {
|
|
2740
|
+
const action = result.created ? "Created" : "Updated";
|
|
2741
|
+
console.log(`${action} rules file: ${result.filePath}`);
|
|
2742
|
+
console.log(` Preferences injected: ${result.prefCount}`);
|
|
2743
|
+
console.log(` Project conventions: ${result.conventionCount}`);
|
|
2726
2744
|
}
|
|
2727
|
-
const action = result.created ? "Created" : "Updated";
|
|
2728
|
-
console.log(`${action} rules file: ${result.filePath}`);
|
|
2729
|
-
console.log(` Preferences injected: ${result.prefCount}`);
|
|
2730
|
-
console.log(` Project conventions: ${result.conventionCount}`);
|
|
2731
2745
|
console.log(`\nContent is inside <!-- GNOSYS:START --> / <!-- GNOSYS:END --> markers.`);
|
|
2732
2746
|
console.log(`User content outside these markers is preserved.`);
|
|
2733
2747
|
}
|