promptlike 0.5.0 → 0.6.1

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,105 @@
1
+ "use strict";
2
+ /**
3
+ * User preferences for the CLI — `~/.config/promptlike/settings.json`.
4
+ *
5
+ * Deliberately NOT in config.json: that file holds the session and is
6
+ * rewritten on every token refresh and deleted on logout, which would silently
7
+ * reset a preference the user set once.
8
+ *
9
+ * Today there is one key: `suggest` (on/off) — the Claude Code hook and
10
+ * `ple suggest --hook` stay silent when it is off.
11
+ */
12
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
13
+ if (k2 === undefined) k2 = k;
14
+ var desc = Object.getOwnPropertyDescriptor(m, k);
15
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
16
+ desc = { enumerable: true, get: function() { return m[k]; } };
17
+ }
18
+ Object.defineProperty(o, k2, desc);
19
+ }) : (function(o, m, k, k2) {
20
+ if (k2 === undefined) k2 = k;
21
+ o[k2] = m[k];
22
+ }));
23
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
24
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
25
+ }) : function(o, v) {
26
+ o["default"] = v;
27
+ });
28
+ var __importStar = (this && this.__importStar) || (function () {
29
+ var ownKeys = function(o) {
30
+ ownKeys = Object.getOwnPropertyNames || function (o) {
31
+ var ar = [];
32
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
33
+ return ar;
34
+ };
35
+ return ownKeys(o);
36
+ };
37
+ return function (mod) {
38
+ if (mod && mod.__esModule) return mod;
39
+ var result = {};
40
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
41
+ __setModuleDefault(result, mod);
42
+ return result;
43
+ };
44
+ })();
45
+ Object.defineProperty(exports, "__esModule", { value: true });
46
+ exports.SETTING_KEYS = void 0;
47
+ exports.configDir = configDir;
48
+ exports.readSettings = readSettings;
49
+ exports.writeSettings = writeSettings;
50
+ exports.parseOnOff = parseOnOff;
51
+ exports.suggestEnabled = suggestEnabled;
52
+ const fs = __importStar(require("fs"));
53
+ const os = __importStar(require("os"));
54
+ const path = __importStar(require("path"));
55
+ exports.SETTING_KEYS = ['suggest'];
56
+ /** Config dir (same as the session file). `PROMPTLIKE_CONFIG_DIR` overrides it for tests. */
57
+ function configDir() {
58
+ const override = process.env.PROMPTLIKE_CONFIG_DIR;
59
+ if (override && override.trim())
60
+ return override.trim();
61
+ return path.join(os.homedir(), '.config', 'promptlike');
62
+ }
63
+ function settingsFile() {
64
+ return path.join(configDir(), 'settings.json');
65
+ }
66
+ function readSettings() {
67
+ try {
68
+ const raw = JSON.parse(fs.readFileSync(settingsFile(), 'utf-8'));
69
+ const out = {};
70
+ if (raw.suggest === 'on' || raw.suggest === 'off')
71
+ out.suggest = raw.suggest;
72
+ return out;
73
+ }
74
+ catch {
75
+ return {};
76
+ }
77
+ }
78
+ function writeSettings(next) {
79
+ fs.mkdirSync(configDir(), { recursive: true, mode: 0o700 });
80
+ fs.writeFileSync(settingsFile(), JSON.stringify(next, null, 2) + '\n', { mode: 0o600 });
81
+ }
82
+ /** Parse a user-typed on/off value. */
83
+ function parseOnOff(value) {
84
+ const v = value.trim().toLowerCase();
85
+ if (['on', 'true', '1', 'yes'].includes(v))
86
+ return 'on';
87
+ if (['off', 'false', '0', 'no'].includes(v))
88
+ return 'off';
89
+ throw new Error(`Expected on or off, got '${value}'.`);
90
+ }
91
+ const OFF_VALUES = new Set(['off', 'false', '0', 'no']);
92
+ /**
93
+ * Suggestions are on unless switched off in any of three places:
94
+ * `PLE_SUGGEST=off`, the Claude Code plugin option (exported to hooks as
95
+ * `CLAUDE_PLUGIN_OPTION_SUGGESTIONS`), or `ple config set suggest off`.
96
+ */
97
+ function suggestEnabled(env = process.env, settings = readSettings()) {
98
+ const envValue = env.PLE_SUGGEST?.trim().toLowerCase();
99
+ if (envValue && OFF_VALUES.has(envValue))
100
+ return false;
101
+ const pluginValue = env.CLAUDE_PLUGIN_OPTION_SUGGESTIONS?.trim().toLowerCase();
102
+ if (pluginValue && OFF_VALUES.has(pluginValue))
103
+ return false;
104
+ return settings.suggest !== 'off';
105
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "promptlike",
3
- "version": "0.5.0",
3
+ "version": "0.6.1",
4
4
  "description": "Terminal access to your PromptLikeEngineer prompt library - search, read, and copy your saved prompts without leaving the shell.",
5
5
  "bin": {
6
6
  "ple": "dist/index.js"