paper-mono 0.62.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.
@@ -0,0 +1,55 @@
1
+ // src/config.ts
2
+ import { existsSync, readFileSync } from "node:fs";
3
+ import { homedir } from "node:os";
4
+ import { dirname, join, resolve } from "node:path";
5
+ import { fileURLToPath } from "node:url";
6
+ var moduleDir = dirname(fileURLToPath(import.meta.url));
7
+ function getPackageDir() {
8
+ const configured = process.env.PAPER_PACKAGE_DIR;
9
+ if (configured === "~") return homedir();
10
+ if (configured?.startsWith("~/")) return join(homedir(), configured.slice(2));
11
+ if (configured) return resolve(configured);
12
+ let current = moduleDir;
13
+ while (current !== dirname(current)) {
14
+ if (existsSync(join(current, "package.json"))) return current;
15
+ current = dirname(current);
16
+ }
17
+ return moduleDir;
18
+ }
19
+ var manifest = JSON.parse(readFileSync(join(getPackageDir(), "package.json"), "utf8"));
20
+ var APP_NAME = manifest.piConfig?.name ?? "paper";
21
+ var OWNER_COMMAND = "paper mono";
22
+ var PUBLIC_PROMISE = "Turn a Paper reference into a sharp implementation brief, get explicit approval, then carry it faithfully into production code.";
23
+ var IDENTITY_DOMAIN = "Paper Desktop design-to-code workflows";
24
+ var CONFIG_DIR_NAME = manifest.piConfig?.configDir ?? ".paper";
25
+ var VERSION = manifest.version ?? "0.0.0";
26
+ var ENV_AGENT_DIR = "PAPER_CODING_AGENT_DIR";
27
+ var PACKAGE_DISTRIBUTION = manifest.paperMono?.distribution ?? "workspace";
28
+ var BUNDLED_PACKAGE_VERSIONS = Object.freeze(
29
+ manifest.paperMono?.bundledPackages ?? {}
30
+ );
31
+ function applyPaperPrivacyDefaults(environment = process.env) {
32
+ environment.PI_TELEMETRY = "0";
33
+ environment.PI_SKIP_VERSION_CHECK = "1";
34
+ }
35
+ function getAgentDir() {
36
+ const configured = process.env[ENV_AGENT_DIR];
37
+ if (configured === "~") return homedir();
38
+ if (configured?.startsWith("~/")) return join(homedir(), configured.slice(2));
39
+ if (configured) return resolve(configured);
40
+ return join(homedir(), CONFIG_DIR_NAME, "agent");
41
+ }
42
+
43
+ export {
44
+ getPackageDir,
45
+ APP_NAME,
46
+ OWNER_COMMAND,
47
+ PUBLIC_PROMISE,
48
+ IDENTITY_DOMAIN,
49
+ CONFIG_DIR_NAME,
50
+ VERSION,
51
+ PACKAGE_DISTRIBUTION,
52
+ BUNDLED_PACKAGE_VERSIONS,
53
+ applyPaperPrivacyDefaults,
54
+ getAgentDir
55
+ };
@@ -0,0 +1,171 @@
1
+ import {
2
+ APP_NAME,
3
+ OWNER_COMMAND,
4
+ PUBLIC_PROMISE
5
+ } from "./chunk-BGKLQ5Y6.js";
6
+
7
+ // src/workflow-contract.ts
8
+ var PAPER_IMPLEMENTATION_BRIEF_SCHEMA_VERSION = "paper-implementation-brief.v1";
9
+ var PAPER_BRIEF_APPROVAL_PREFIX = "APPROVE PAPER BRIEF";
10
+ function isEnabledWorkflowFlag(value) {
11
+ return value === true || typeof value === "string" && ["1", "true", "yes"].includes(value.trim().toLowerCase());
12
+ }
13
+ function resolvePaperWorkflowMode(auditOnly, copilot) {
14
+ if (isEnabledWorkflowFlag(auditOnly) && isEnabledWorkflowFlag(copilot)) {
15
+ throw new TypeError("--audit-only and --copilot are mutually exclusive Paper workflow modes.");
16
+ }
17
+ if (isEnabledWorkflowFlag(auditOnly)) return "audit-only";
18
+ if (isEnabledWorkflowFlag(copilot)) return "copilot";
19
+ return "reference-to-code";
20
+ }
21
+ var PAPER_TOOL_SAFETY_CLASSIFICATIONS = Object.freeze({
22
+ paper_get_basic_info: "read-only",
23
+ paper_get_selection: "read-only",
24
+ paper_get_node_info: "read-only",
25
+ paper_get_children: "read-only",
26
+ paper_get_tree_summary: "read-only",
27
+ paper_get_screenshot: "read-only",
28
+ paper_get_jsx: "read-only",
29
+ paper_get_computed_styles: "read-only",
30
+ paper_get_fill_image: "read-only",
31
+ paper_find_nodes: "read-only",
32
+ paper_get_font_family_info: "read-only",
33
+ paper_get_guide: "read-only",
34
+ paper_find_placement: "read-only",
35
+ paper_get_tokens: "read-only",
36
+ paper_mcp_reachability_check: "read-only",
37
+ paper_capture_provenance: "read-only",
38
+ paper_style_tokens_extract: "dry-run-or-live-mutation",
39
+ paper_materialize_system_direction: "dry-run-or-live-mutation",
40
+ paper_create_page: "live-mutation",
41
+ paper_open_page: "live-mutation",
42
+ paper_create_tokens: "dry-run-or-live-mutation",
43
+ paper_set_tokens: "dry-run-or-live-mutation",
44
+ paper_write_html: "dry-run-or-live-mutation",
45
+ paper_move_nodes: "dry-run-or-live-mutation",
46
+ paper_rename_nodes: "dry-run-or-live-mutation",
47
+ paper_revise_artboard: "dry-run-or-live-mutation",
48
+ paper_delete_nodes: "dry-run-or-live-mutation"
49
+ });
50
+ var PAPER_MUTATION_TOOL_NAMES = [
51
+ "paper_style_tokens_extract",
52
+ "paper_materialize_system_direction",
53
+ "paper_create_page",
54
+ "paper_open_page",
55
+ "paper_create_tokens",
56
+ "paper_set_tokens",
57
+ "paper_write_html",
58
+ "paper_move_nodes",
59
+ "paper_rename_nodes",
60
+ "paper_revise_artboard",
61
+ "paper_delete_nodes"
62
+ ];
63
+ var PAPER_TOOL_IDS = Object.freeze([
64
+ "paper_get_basic_info",
65
+ "paper_get_selection",
66
+ "paper_get_node_info",
67
+ "paper_get_children",
68
+ "paper_get_tree_summary",
69
+ "paper_get_screenshot",
70
+ "paper_get_jsx",
71
+ "paper_get_computed_styles",
72
+ "paper_get_fill_image",
73
+ "paper_get_font_family_info",
74
+ "paper_get_guide",
75
+ "paper_find_placement",
76
+ "paper_mcp_reachability_check",
77
+ "paper_style_tokens_extract",
78
+ "paper_materialize_system_direction",
79
+ "paper_create_page",
80
+ "paper_open_page",
81
+ "paper_rename_nodes",
82
+ "paper_revise_artboard",
83
+ "paper_delete_nodes",
84
+ "paper_find_nodes",
85
+ "paper_get_tokens",
86
+ "paper_capture_provenance",
87
+ "paper_create_tokens",
88
+ "paper_set_tokens",
89
+ "paper_write_html",
90
+ "paper_move_nodes"
91
+ ]);
92
+
93
+ // src/owner-help.ts
94
+ var STANDARD_TOOL_IDS = ["read", "bash", "edit", "write", "grep", "find", "ls"];
95
+ function printHelp() {
96
+ process.stdout.write(`${OWNER_COMMAND} - Paper Desktop design-to-code specialist
97
+
98
+ ${PUBLIC_PROMISE}
99
+
100
+ Usage:
101
+ ${OWNER_COMMAND} [options] [@files...] [messages...]
102
+ ${APP_NAME} [options] [@files...] [messages...]
103
+
104
+ Arguments:
105
+ @file Attach a regular file contained by the current repository
106
+ messages... Send initial prompt text to the specialist
107
+ -- messages... Treat following option-shaped text as specialist prompt input
108
+
109
+ Commands:
110
+ ${APP_NAME} show|info [--json] Show the open Paper document
111
+ ${APP_NAME} selection [--json] Show the current Paper selection
112
+ ${APP_NAME} tree [--json] Show the open document tree
113
+ ${APP_NAME} node <id> [options] Inspect node info, children, or JSX
114
+ ${APP_NAME} screenshot --out <file> Save a node or single-selection screenshot
115
+ ${APP_NAME} doctor [--json] Check all 27 Paper tools and reachability
116
+ ${OWNER_COMMAND} [options] Start the guarded design-to-code specialist
117
+
118
+ Options:
119
+ --about-json Print identity, privacy, lock, workflow, and provenance receipts
120
+ --audit-only Permanently read-only audit workflow
121
+ --copilot Guarded Paper copilot workflow; still requires brief approval
122
+ --continue, -c Continue the most recent session
123
+ --resume, -r Select a session to resume
124
+ --session <id> Open a verified session ID; path-like values are rejected
125
+ --fork <path-or-id> Fork a session into the current project
126
+ --session-dir <dir> Override session storage and lookup
127
+ --no-session Use an in-memory session
128
+ --provider <name> Select a provider
129
+ --model <provider/id-or-pattern> Select a model
130
+ --api-key <key> Runtime-only API key; requires --model
131
+ --thinking <level> off|minimal|low|medium|high|xhigh
132
+ --list-models [search] List available models
133
+ --mode <mode> text|json (RPC is disabled by the approval boundary)
134
+ --print, -p Process prompts and exit
135
+ --tools <ids> Select shared or Paper tools
136
+ --no-tools Disable all tools
137
+ --skill <path> Load a skill path
138
+ --no-skills, -ns Disable skills
139
+ --prompt-template <path> Load a prompt-template path
140
+ --no-prompt-templates, -np Disable prompt templates
141
+ --theme <path> Load a theme path
142
+ --no-themes Disable themes
143
+ --system-prompt <text> Override the Paper prompt
144
+ --append-system-prompt <text> Append prompt policy (repeatable)
145
+ --offline Disable startup network operations
146
+ --verbose Show verbose startup detail
147
+ --version, -v Print the Paper package version
148
+ --help, -h Show this help
149
+
150
+ Environment:
151
+ PAPER_CODING_AGENT_DIR Agent home (default: ~/.paper/agent)
152
+ PAPER_OFFLINE Disable startup network operations
153
+
154
+ Registered capabilities (mutation remains locked until exact brief approval):
155
+ ${[...STANDARD_TOOL_IDS, ...PAPER_TOOL_IDS].join(", ")}
156
+
157
+ Safety:
158
+ External extension discovery and direct page commands are disabled. Mutation stays locked until the exact APPROVE PAPER BRIEF <brief-id> phrase for the current brief.
159
+ `);
160
+ }
161
+
162
+ export {
163
+ PAPER_IMPLEMENTATION_BRIEF_SCHEMA_VERSION,
164
+ PAPER_BRIEF_APPROVAL_PREFIX,
165
+ resolvePaperWorkflowMode,
166
+ PAPER_TOOL_SAFETY_CLASSIFICATIONS,
167
+ PAPER_MUTATION_TOOL_NAMES,
168
+ PAPER_TOOL_IDS,
169
+ STANDARD_TOOL_IDS,
170
+ printHelp
171
+ };
@@ -0,0 +1,31 @@
1
+ // src/cli/diagnostics.ts
2
+ var PAPER_HELP_HINT = "Run `paper --help` for supported commands and options.";
3
+ var CREDENTIAL_OPTION_TERMS = /* @__PURE__ */ new Set([
4
+ "auth",
5
+ "authorization",
6
+ "credential",
7
+ "credentials",
8
+ "key",
9
+ "password",
10
+ "passphrase",
11
+ "secret",
12
+ "token"
13
+ ]);
14
+ function isCredentialShapedOption(option) {
15
+ return option.slice(2).toLowerCase().split(/[-_]/u).some((term) => CREDENTIAL_OPTION_TERMS.has(term));
16
+ }
17
+ function safeArgumentForDiagnostic(token) {
18
+ const separator = token.indexOf("=");
19
+ if (!token.startsWith("--")) return token;
20
+ if (separator < 0) return isCredentialShapedOption(token) ? `${token} [REDACTED]` : token;
21
+ const option = token.slice(0, separator);
22
+ return `${option}=[REDACTED]`;
23
+ }
24
+ function invalidPaperArgument(message) {
25
+ throw new TypeError(`${message} ${PAPER_HELP_HINT}`);
26
+ }
27
+
28
+ export {
29
+ safeArgumentForDiagnostic,
30
+ invalidPaperArgument
31
+ };