@notation/factory-cursor 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Notation Labs Ltd
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,26 @@
1
+ import { ResourceGroup } from "@notation/resource";
2
+ import {
3
+ type Account as AccountContract,
4
+ type VaultSecret,
5
+ } from "@notation/factory";
6
+ import { runtime } from "./runtime.ts";
7
+
8
+ export type AccountOptions = {
9
+ /**
10
+ * A Cursor API key, as a secret in the hub's vault, such as
11
+ * `vault.secret({ id: "cursor-api-key", value: key.credentials.value })`.
12
+ * Generate one on the Cursor dashboard, under API Keys.
13
+ */
14
+ auth: VaultSecret;
15
+ };
16
+
17
+ /** The credentials Cursor Agent runs on. The deployer binds them, and injects them into every container that lists `cursor.runtime`, and no other. */
18
+ export class Account extends ResourceGroup implements AccountContract {
19
+ readonly runtime = runtime;
20
+ readonly secrets: Record<string, VaultSecret>;
21
+
22
+ constructor(id: string, { auth }: AccountOptions) {
23
+ super("cursor/Account", id, {});
24
+ this.secrets = { CURSOR_API_KEY: auth };
25
+ }
26
+ }
@@ -0,0 +1,39 @@
1
+ import { type Agent as AgentContract, OutpostGroup } from "@notation/factory";
2
+ import * as v from "valibot";
3
+ import { runtime } from "./runtime.ts";
4
+
5
+ const agentConfig = v.object({
6
+ /**
7
+ * Passed as `--model`. A parameterized model takes its parameters in
8
+ * brackets, such as `claude-opus-4-8[effort=high]`.
9
+ */
10
+ model: v.string(),
11
+ /**
12
+ * `plan` and `ask` are read-only. Without it, the CLI edits and runs
13
+ * commands, which is its default mode. `agent` is that default, and the
14
+ * CLI rejects it as a `--mode` value.
15
+ */
16
+ mode: v.optional(v.picklist(["plan", "ask"])),
17
+ /** Relative to `.factory/`. Appended to the runner's prompt. */
18
+ systemPrompt: v.optional(v.string()),
19
+ /** Merged into `~/.cursor/cli-config.json` before each run. */
20
+ settings: v.optional(v.record(v.string(), v.unknown())),
21
+ /** `~/.cursor/*` is written to `/data/agents/<id>/`, other `~/*` to `/data/home/`. */
22
+ files: v.optional(v.record(v.string(), v.string())),
23
+ });
24
+ export type AgentConfig = v.InferInput<typeof agentConfig>;
25
+
26
+ export type AgentOptions = AgentConfig;
27
+
28
+ /** A Cursor Agent. A trigger that runs it must target a container that lists `cursor.runtime`. */
29
+ export class Agent extends OutpostGroup<AgentConfig> implements AgentContract {
30
+ readonly runtime = runtime;
31
+
32
+ constructor(id: string, config: AgentOptions) {
33
+ const settings = v.parse(agentConfig, config);
34
+ super("cursor/Agent", id, config);
35
+ this.outpost.store.contribute({
36
+ agents: { [id]: { runtime: runtime.id, ...settings } },
37
+ });
38
+ }
39
+ }
@@ -0,0 +1,3 @@
1
+ export { Account, type AccountOptions } from "./account.ts";
2
+ export { Agent, type AgentOptions } from "./agent.ts";
3
+ export { runtime } from "./runtime.ts";
@@ -0,0 +1,13 @@
1
+ import { readFileSync } from "node:fs";
2
+ import type { Runtime } from "@notation/factory";
3
+
4
+ /** Cursor Agent. `setup` installs its CLI, `agent`, in a container's image, and `runner` is how the runner runs it. Both are read lazily: an outpost's config, which has no filesystem, never touches them. */
5
+ export const runtime: Runtime = {
6
+ id: "cursor",
7
+ get setup() {
8
+ return readFileSync(new URL("../runtime/setup.sh", import.meta.url), "utf8");
9
+ },
10
+ get runner() {
11
+ return readFileSync(new URL("../runtime/runner.ts", import.meta.url), "utf8");
12
+ },
13
+ };
package/package.json CHANGED
@@ -1,6 +1,32 @@
1
1
  {
2
2
  "name": "@notation/factory-cursor",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.2.0",
4
+ "author": "Daniel Grant",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/notationlabs/factory.git",
9
+ "directory": "packages/cursor"
10
+ },
11
+ "type": "module",
12
+ "exports": {
13
+ ".": "./implementations/index.ts"
14
+ },
15
+ "files": [
16
+ "implementations",
17
+ "runtime"
18
+ ],
19
+ "publishConfig": {
20
+ "access": "public"
21
+ },
22
+ "dependencies": {
23
+ "@notation/resource": "0.28.1",
24
+ "valibot": "^1.1.0"
25
+ },
26
+ "peerDependencies": {
27
+ "@notation/factory": "^0.2.0"
28
+ },
29
+ "devDependencies": {
30
+ "@notation/factory": "0.2.0"
31
+ }
6
32
  }
@@ -0,0 +1,68 @@
1
+ import { mkdir, readFile, writeFile } from "node:fs/promises";
2
+ import { homedir } from "node:os";
3
+ import { dirname, join } from "node:path";
4
+ import type { RuntimeRunner } from "@notation/factory";
5
+
6
+ /** How the runner runs Cursor Agent. Containers import it with no packages, so it imports only Node's. */
7
+ const cursor: RuntimeRunner = {
8
+ command: "agent",
9
+ name: "Cursor Agent",
10
+ transcripts: join(homedir(), ".cursor", "chats"),
11
+ args: async (run, { systemPrompt }) => {
12
+ const { agent } = run;
13
+ // The CLI has no public flag for a system prompt, so the runner's
14
+ // prompt, then the agent's, come before the conversation's messages.
15
+ const args = [
16
+ "-p",
17
+ "--output-format",
18
+ "json",
19
+ "--force",
20
+ "--trust",
21
+ "--sandbox",
22
+ "disabled",
23
+ "--disable-auto-update",
24
+ `${systemPrompt}\n\n${run.conversation.prompt}`,
25
+ ];
26
+ if (typeof agent.model === "string") args.push("--model", agent.model);
27
+ if (agent.mode === "plan" || agent.mode === "ask") args.push("--mode", agent.mode);
28
+ if (agent.settings && typeof agent.settings === "object") {
29
+ // The CLI reads one config for the user, which a run merges for itself.
30
+ const path = join(homedir(), ".cursor", "cli-config.json");
31
+ await mkdir(dirname(path), { recursive: true });
32
+ let current: Record<string, unknown> = {};
33
+ try {
34
+ const parsed: unknown = JSON.parse(await readFile(path, "utf8"));
35
+ if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) current = parsed as Record<string, unknown>;
36
+ } catch {
37
+ // The CLI creates the file itself when it has never run.
38
+ }
39
+ const settings = agent.settings as Record<string, unknown>;
40
+ await writeFile(
41
+ path,
42
+ `${JSON.stringify(
43
+ {
44
+ version: 1,
45
+ editor: { vimMode: false },
46
+ permissions: { allow: [], deny: [] },
47
+ ...current,
48
+ ...settings,
49
+ },
50
+ null,
51
+ 2,
52
+ )}\n`,
53
+ );
54
+ }
55
+ return args;
56
+ },
57
+ resume: (sessionId) => ["--resume", sessionId],
58
+ parse: (stdout) => {
59
+ try {
60
+ const output = JSON.parse(stdout) as { result?: string; is_error?: boolean; session_id?: string };
61
+ return { result: output.result, isError: output.is_error, sessionId: output.session_id };
62
+ } catch {
63
+ return undefined;
64
+ }
65
+ },
66
+ };
67
+
68
+ export default cursor;
@@ -0,0 +1,16 @@
1
+ # Installs Cursor Agent system-wide. Runs as root at image build. The
2
+ # installer puts the CLI in root's home, which the factory user can't read,
3
+ # and the CLI is a directory of node and JavaScript, not one binary.
4
+ set -e
5
+ if ! command -v curl >/dev/null 2>&1; then
6
+ apt-get update
7
+ apt-get install -y --no-install-recommends ca-certificates curl
8
+ rm -rf /var/lib/apt/lists/*
9
+ fi
10
+ curl -fsSL https://cursor.com/install | bash
11
+ dir="$(dirname "$(readlink -f /root/.local/bin/agent)")"
12
+ rm -rf /opt/cursor-agent
13
+ mv "$dir" /opt/cursor-agent
14
+ chmod -R a+rX /opt/cursor-agent
15
+ ln -sfn /opt/cursor-agent/cursor-agent /usr/local/bin/agent
16
+ rm -rf /root/.local /root/.cursor
package/README.md DELETED
@@ -1,3 +0,0 @@
1
- # Temporary Holding Version
2
-
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.