@agentoryhq/adapter-cursor 0.1.1 → 0.1.3

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/align.d.ts CHANGED
@@ -1,7 +1,10 @@
1
1
  import type { ApplyAlignOpts, ApplyAlignResult } from "@agentoryhq/runtime-contract";
2
2
  /**
3
3
  * Write confirmed align patch to Cursor project files.
4
- * Snapshots prior mcp.json under `.cursor/agentory-snapshots/`.
4
+ * - MCP → `.cursor/mcp.json`;Skills 名单 → `.cursor/agentory-skills.json`
5
+ * - Rules → `.cursor/rules/<名>.mdc`(rules-desired-config:body 原样落盘,
6
+ * 不追加结尾换行——hash 契约 = sha256(文件字节) 与上报 contentHash 同值)
7
+ * Snapshots prior mcp.json and overwritten rule files under `.cursor/agentory-snapshots/`.
5
8
  * All-or-nothing: on failure restores snapshot when possible.
6
9
  */
7
10
  export declare function applyAlignPatch(opts: ApplyAlignOpts): ApplyAlignResult;
package/dist/align.js CHANGED
Binary file
package/dist/discover.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import fs from "node:fs";
2
+ import { createHash } from "node:crypto";
2
3
  import path from "node:path";
3
4
  function readJsonFile(file) {
4
5
  try {
@@ -41,6 +42,42 @@ function skillsFromDir(dir) {
41
42
  return [];
42
43
  }
43
44
  }
45
+ /**
46
+ * 规则发现(rules-desired-config):扫 `.cursor/rules/*.mdc`,只报名字 + 内容 sha256,
47
+ * 正文永不出节点(会话流索引只读口径不变)。name = 去 .mdc 扩展名的文件名。
48
+ * hash 契约:sha256(文件字节) = API 侧 ruleBodyHash(body)——文件 = body 原样。
49
+ * dirs 顺序 = cwd → home,先见优先(cwd 优先,与 asset-index 口径一致)。
50
+ */
51
+ function rulesFromDirs(dirs) {
52
+ const byName = new Map();
53
+ for (const dir of dirs) {
54
+ let entries;
55
+ try {
56
+ entries = fs.readdirSync(dir);
57
+ }
58
+ catch {
59
+ continue;
60
+ }
61
+ for (const file of entries) {
62
+ if (!file.endsWith(".mdc"))
63
+ continue;
64
+ const name = file.slice(0, -".mdc".length);
65
+ if (!name || byName.has(name))
66
+ continue;
67
+ const full = path.join(dir, file);
68
+ try {
69
+ if (!fs.statSync(full).isFile())
70
+ continue;
71
+ const contentHash = createHash("sha256").update(fs.readFileSync(full)).digest("hex");
72
+ byName.set(name, { name, contentHash });
73
+ }
74
+ catch {
75
+ continue;
76
+ }
77
+ }
78
+ }
79
+ return [...byName.values()];
80
+ }
44
81
  export function detectCursor(ctx) {
45
82
  const cursorMcpCandidates = [
46
83
  path.join(ctx.cwd, ".cursor", "mcp.json"),
@@ -83,5 +120,9 @@ export function discoverCursorConfig(ctx) {
83
120
  displayName: `Cursor · ${path.basename(ctx.cwd) || "workspace"}`,
84
121
  mcp: cursorMcp,
85
122
  skills: [...skillNames],
123
+ rules: rulesFromDirs([
124
+ path.join(ctx.cwd, ".cursor", "rules"),
125
+ path.join(ctx.homeDir, ".cursor", "rules"),
126
+ ]),
86
127
  };
87
128
  }
package/package.json CHANGED
@@ -1,10 +1,12 @@
1
1
  {
2
2
  "name": "@agentoryhq/adapter-cursor",
3
- "version": "0.1.1",
3
+ "version": "0.1.3",
4
4
  "description": "Agentory RuntimeAdapter for Cursor",
5
5
  "license": "Apache-2.0",
6
6
  "type": "module",
7
- "files": ["dist"],
7
+ "files": [
8
+ "dist"
9
+ ],
8
10
  "exports": {
9
11
  ".": {
10
12
  "types": "./dist/index.d.ts",
@@ -20,8 +22,7 @@
20
22
  },
21
23
  "repository": {
22
24
  "type": "git",
23
- "url": "git+https://github.com/tunsuy/agentory-node.git",
24
- "directory": "adapters/cursor"
25
+ "url": "git+https://github.com/tunsuy/agentory-node.git"
25
26
  },
26
27
  "publishConfig": {
27
28
  "access": "public"