@hasna/prompts 0.3.5 → 0.3.7
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 +170 -0
- package/dist/cli/index.js +13 -5
- package/dist/db/database.d.ts.map +1 -1
- package/dist/index.js +13 -5
- package/dist/mcp/index.js +13 -5
- package/dist/server/index.js +32 -5
- package/package.json +2 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,170 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship made available under
|
|
36
|
+
the License, as indicated by a copyright notice that is included in
|
|
37
|
+
or attached to the work (an example is provided in the Appendix below).
|
|
38
|
+
|
|
39
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
40
|
+
form, that is based on (or derived from) the Work and for which the
|
|
41
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
42
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
43
|
+
of this License, Derivative Works shall not include works that remain
|
|
44
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
45
|
+
the Work and Derivative Works thereof.
|
|
46
|
+
|
|
47
|
+
"Contribution" shall mean, as submitted to the Licensor for inclusion
|
|
48
|
+
in the Work by the copyright owner or by an individual or Legal Entity
|
|
49
|
+
authorized to submit on behalf of the copyright owner. For the purposes
|
|
50
|
+
of this definition, "submitted" means any form of electronic, verbal,
|
|
51
|
+
or written communication sent to the Licensor or its representatives,
|
|
52
|
+
including but not limited to communication on electronic mailing lists,
|
|
53
|
+
source code control systems, and issue tracking systems that are managed
|
|
54
|
+
by, or on behalf of, the Licensor for the purpose of recording and
|
|
55
|
+
discussing the Work, but excluding communication that is conspicuously
|
|
56
|
+
marked or designated in writing by the copyright owner as "Not a
|
|
57
|
+
Contribution."
|
|
58
|
+
|
|
59
|
+
"Contributor" shall mean Licensor and any Legal Entity on behalf of
|
|
60
|
+
whom a Contribution has been received by the Licensor and included
|
|
61
|
+
within the Work.
|
|
62
|
+
|
|
63
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
64
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
65
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
66
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
67
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
68
|
+
Work and such Derivative Works in Source or Object form.
|
|
69
|
+
|
|
70
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
71
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
72
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
73
|
+
(except as stated in this section) patent license to make, have made,
|
|
74
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
75
|
+
where such license applies only to those patent contributions
|
|
76
|
+
Licensors can make available under this License.
|
|
77
|
+
|
|
78
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
79
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
80
|
+
modifications, and in Source or Object form, provided that You
|
|
81
|
+
meet the following conditions:
|
|
82
|
+
|
|
83
|
+
(a) You must give any other recipients of the Work or Derivative Works
|
|
84
|
+
a copy of this License; and
|
|
85
|
+
|
|
86
|
+
(b) You must cause any modified files to carry prominent notices
|
|
87
|
+
stating that You changed the files; and
|
|
88
|
+
|
|
89
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
90
|
+
that You distribute, all copyright, patent, trademark, and
|
|
91
|
+
attribution notices from the Source form of the Work,
|
|
92
|
+
excluding those notices that do not pertain to any part of
|
|
93
|
+
the Derivative Works; and
|
|
94
|
+
|
|
95
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
96
|
+
distribution, You must include a readable copy of the attribution
|
|
97
|
+
notices contained within such NOTICE file, in at least one
|
|
98
|
+
of the following places: within a NOTICE text file distributed
|
|
99
|
+
as part of the Derivative Works; within the Source form or
|
|
100
|
+
documentation, if provided along with the Derivative Works; or,
|
|
101
|
+
within a display generated by the Derivative Works, if and
|
|
102
|
+
wherever such third-party notices normally appear. The contents
|
|
103
|
+
of the NOTICE file are for informational purposes only and
|
|
104
|
+
do not modify the License. You may add Your own attribution
|
|
105
|
+
notices within Derivative Works that You distribute, alongside
|
|
106
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
107
|
+
that such additional attribution notices cannot be construed
|
|
108
|
+
as modifying the License.
|
|
109
|
+
|
|
110
|
+
You may add Your own license statement for Your modifications and
|
|
111
|
+
may provide additional grant of rights to use, copy, modify, merge,
|
|
112
|
+
publish, distribute, sublicense, and/or sell copies of the Software.
|
|
113
|
+
|
|
114
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
115
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
116
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
117
|
+
this License, without any additional terms or conditions.
|
|
118
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
119
|
+
the terms of any separate license agreement you may have executed
|
|
120
|
+
with Licensor regarding such Contributions.
|
|
121
|
+
|
|
122
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
123
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
124
|
+
except as required for reasonable and customary use in describing the
|
|
125
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
126
|
+
|
|
127
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
128
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
129
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
130
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
131
|
+
implied, including, without limitation, any warranties or conditions
|
|
132
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
133
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
134
|
+
appropriateness of using or redistributing the Work and assume any
|
|
135
|
+
risks associated with Your exercise of permissions under this License.
|
|
136
|
+
|
|
137
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
138
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
139
|
+
unless required by applicable law (such as deliberate and grossly
|
|
140
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
141
|
+
liable to You for damages, including any direct, indirect, special,
|
|
142
|
+
incidental, or exemplary damages of any character arising as a
|
|
143
|
+
result of this License or out of the use or inability to use the
|
|
144
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
145
|
+
work stoppage, computer failure or malfunction, or all other
|
|
146
|
+
commercial damages or losses), even if such Contributor has been
|
|
147
|
+
advised of the possibility of such damages.
|
|
148
|
+
|
|
149
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
150
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
151
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
152
|
+
or other liability obligations and/or rights consistent with this
|
|
153
|
+
License. However, in accepting such obligations, You may offer only
|
|
154
|
+
conditions consistent with this License.
|
|
155
|
+
|
|
156
|
+
END OF TERMS AND CONDITIONS
|
|
157
|
+
|
|
158
|
+
Copyright 2024 hasna.com
|
|
159
|
+
|
|
160
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
161
|
+
you may not use this file except in compliance with the License.
|
|
162
|
+
You may obtain a copy of the License at
|
|
163
|
+
|
|
164
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
165
|
+
|
|
166
|
+
Unless required by applicable law or agreed to in writing, software
|
|
167
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
168
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
169
|
+
See the License for the specific language governing permissions and
|
|
170
|
+
limitations under the License.
|
package/dist/cli/index.js
CHANGED
|
@@ -2084,11 +2084,11 @@ var require_commander = __commonJS((exports) => {
|
|
|
2084
2084
|
// src/db/database.ts
|
|
2085
2085
|
import { Database } from "bun:sqlite";
|
|
2086
2086
|
import { join } from "path";
|
|
2087
|
-
import { existsSync, mkdirSync } from "fs";
|
|
2087
|
+
import { existsSync, mkdirSync, cpSync } from "fs";
|
|
2088
2088
|
function getDbPath() {
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2089
|
+
const envPath = process.env["HASNA_PROMPTS_DB_PATH"] ?? process.env["PROMPTS_DB_PATH"];
|
|
2090
|
+
if (envPath)
|
|
2091
|
+
return envPath;
|
|
2092
2092
|
if (process.env["PROMPTS_DB_SCOPE"] === "project") {
|
|
2093
2093
|
let dir = process.cwd();
|
|
2094
2094
|
while (true) {
|
|
@@ -2103,7 +2103,15 @@ function getDbPath() {
|
|
|
2103
2103
|
}
|
|
2104
2104
|
}
|
|
2105
2105
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
2106
|
-
|
|
2106
|
+
const newDir = join(home, ".hasna", "prompts");
|
|
2107
|
+
const oldDir = join(home, ".prompts");
|
|
2108
|
+
if (!existsSync(newDir) && existsSync(oldDir)) {
|
|
2109
|
+
try {
|
|
2110
|
+
mkdirSync(join(home, ".hasna"), { recursive: true });
|
|
2111
|
+
cpSync(oldDir, newDir, { recursive: true });
|
|
2112
|
+
} catch {}
|
|
2113
|
+
}
|
|
2114
|
+
return join(newDir, "prompts.db");
|
|
2107
2115
|
}
|
|
2108
2116
|
function getDatabase() {
|
|
2109
2117
|
if (_db)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAMrC,wBAAgB,SAAS,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../src/db/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAA;AAMrC,wBAAgB,SAAS,IAAI,MAAM,CAmClC;AAED,wBAAgB,WAAW,IAAI,QAAQ,CAmBtC;AAED,wBAAgB,aAAa,IAAI,IAAI,CAKpC;AAGD,wBAAgB,aAAa,IAAI,IAAI,CAEpC;AA4KD,wBAAgB,cAAc,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA0B5E;AAED,wBAAgB,MAAM,CAAC,EAAE,EAAE,QAAQ,GAAG,OAAO,CAM5C;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAkC3E"}
|
package/dist/index.js
CHANGED
|
@@ -2,12 +2,12 @@
|
|
|
2
2
|
// src/db/database.ts
|
|
3
3
|
import { Database } from "bun:sqlite";
|
|
4
4
|
import { join } from "path";
|
|
5
|
-
import { existsSync, mkdirSync } from "fs";
|
|
5
|
+
import { existsSync, mkdirSync, cpSync } from "fs";
|
|
6
6
|
var _db = null;
|
|
7
7
|
function getDbPath() {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
const envPath = process.env["HASNA_PROMPTS_DB_PATH"] ?? process.env["PROMPTS_DB_PATH"];
|
|
9
|
+
if (envPath)
|
|
10
|
+
return envPath;
|
|
11
11
|
if (process.env["PROMPTS_DB_SCOPE"] === "project") {
|
|
12
12
|
let dir = process.cwd();
|
|
13
13
|
while (true) {
|
|
@@ -22,7 +22,15 @@ function getDbPath() {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
25
|
-
|
|
25
|
+
const newDir = join(home, ".hasna", "prompts");
|
|
26
|
+
const oldDir = join(home, ".prompts");
|
|
27
|
+
if (!existsSync(newDir) && existsSync(oldDir)) {
|
|
28
|
+
try {
|
|
29
|
+
mkdirSync(join(home, ".hasna"), { recursive: true });
|
|
30
|
+
cpSync(oldDir, newDir, { recursive: true });
|
|
31
|
+
} catch {}
|
|
32
|
+
}
|
|
33
|
+
return join(newDir, "prompts.db");
|
|
26
34
|
}
|
|
27
35
|
function getDatabase() {
|
|
28
36
|
if (_db)
|
package/dist/mcp/index.js
CHANGED
|
@@ -3996,12 +3996,12 @@ var NEVER = INVALID;
|
|
|
3996
3996
|
// src/db/database.ts
|
|
3997
3997
|
import { Database } from "bun:sqlite";
|
|
3998
3998
|
import { join } from "path";
|
|
3999
|
-
import { existsSync, mkdirSync } from "fs";
|
|
3999
|
+
import { existsSync, mkdirSync, cpSync } from "fs";
|
|
4000
4000
|
var _db = null;
|
|
4001
4001
|
function getDbPath() {
|
|
4002
|
-
|
|
4003
|
-
|
|
4004
|
-
|
|
4002
|
+
const envPath = process.env["HASNA_PROMPTS_DB_PATH"] ?? process.env["PROMPTS_DB_PATH"];
|
|
4003
|
+
if (envPath)
|
|
4004
|
+
return envPath;
|
|
4005
4005
|
if (process.env["PROMPTS_DB_SCOPE"] === "project") {
|
|
4006
4006
|
let dir = process.cwd();
|
|
4007
4007
|
while (true) {
|
|
@@ -4016,7 +4016,15 @@ function getDbPath() {
|
|
|
4016
4016
|
}
|
|
4017
4017
|
}
|
|
4018
4018
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
4019
|
-
|
|
4019
|
+
const newDir = join(home, ".hasna", "prompts");
|
|
4020
|
+
const oldDir = join(home, ".prompts");
|
|
4021
|
+
if (!existsSync(newDir) && existsSync(oldDir)) {
|
|
4022
|
+
try {
|
|
4023
|
+
mkdirSync(join(home, ".hasna"), { recursive: true });
|
|
4024
|
+
cpSync(oldDir, newDir, { recursive: true });
|
|
4025
|
+
} catch {}
|
|
4026
|
+
}
|
|
4027
|
+
return join(newDir, "prompts.db");
|
|
4020
4028
|
}
|
|
4021
4029
|
function getDatabase() {
|
|
4022
4030
|
if (_db)
|
package/dist/server/index.js
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
// src/db/database.ts
|
|
5
5
|
import { Database } from "bun:sqlite";
|
|
6
6
|
import { join } from "path";
|
|
7
|
-
import { existsSync, mkdirSync } from "fs";
|
|
7
|
+
import { existsSync, mkdirSync, cpSync } from "fs";
|
|
8
8
|
var _db = null;
|
|
9
9
|
function getDbPath() {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
const envPath = process.env["HASNA_PROMPTS_DB_PATH"] ?? process.env["PROMPTS_DB_PATH"];
|
|
11
|
+
if (envPath)
|
|
12
|
+
return envPath;
|
|
13
13
|
if (process.env["PROMPTS_DB_SCOPE"] === "project") {
|
|
14
14
|
let dir = process.cwd();
|
|
15
15
|
while (true) {
|
|
@@ -24,7 +24,15 @@ function getDbPath() {
|
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
26
|
const home = process.env["HOME"] || process.env["USERPROFILE"] || "~";
|
|
27
|
-
|
|
27
|
+
const newDir = join(home, ".hasna", "prompts");
|
|
28
|
+
const oldDir = join(home, ".prompts");
|
|
29
|
+
if (!existsSync(newDir) && existsSync(oldDir)) {
|
|
30
|
+
try {
|
|
31
|
+
mkdirSync(join(home, ".hasna"), { recursive: true });
|
|
32
|
+
cpSync(oldDir, newDir, { recursive: true });
|
|
33
|
+
} catch {}
|
|
34
|
+
}
|
|
35
|
+
return join(newDir, "prompts.db");
|
|
28
36
|
}
|
|
29
37
|
function getDatabase() {
|
|
30
38
|
if (_db)
|
|
@@ -150,6 +158,25 @@ function runMigrations(db) {
|
|
|
150
158
|
CREATE INDEX IF NOT EXISTS idx_usage_log_used_at ON usage_log(used_at);
|
|
151
159
|
`
|
|
152
160
|
},
|
|
161
|
+
{
|
|
162
|
+
name: "008_schedules",
|
|
163
|
+
sql: `
|
|
164
|
+
CREATE TABLE IF NOT EXISTS prompt_schedules (
|
|
165
|
+
id TEXT PRIMARY KEY,
|
|
166
|
+
prompt_id TEXT NOT NULL REFERENCES prompts(id) ON DELETE CASCADE,
|
|
167
|
+
prompt_slug TEXT NOT NULL,
|
|
168
|
+
cron TEXT NOT NULL,
|
|
169
|
+
vars TEXT NOT NULL DEFAULT '{}',
|
|
170
|
+
agent_id TEXT,
|
|
171
|
+
last_run_at TEXT,
|
|
172
|
+
next_run_at TEXT NOT NULL,
|
|
173
|
+
run_count INTEGER NOT NULL DEFAULT 0,
|
|
174
|
+
created_at TEXT NOT NULL DEFAULT (datetime('now'))
|
|
175
|
+
);
|
|
176
|
+
CREATE INDEX IF NOT EXISTS idx_prompt_schedules_next_run ON prompt_schedules(next_run_at);
|
|
177
|
+
CREATE INDEX IF NOT EXISTS idx_prompt_schedules_prompt_id ON prompt_schedules(prompt_id);
|
|
178
|
+
`
|
|
179
|
+
},
|
|
153
180
|
{
|
|
154
181
|
name: "002_fts5",
|
|
155
182
|
sql: `
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/prompts",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.7",
|
|
4
4
|
"description": "Reusable prompt library for AI agents — CLI + MCP server + REST API + web dashboard",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -49,6 +49,7 @@
|
|
|
49
49
|
"dashboard"
|
|
50
50
|
],
|
|
51
51
|
"publishConfig": {
|
|
52
|
+
"registry": "https://registry.npmjs.org",
|
|
52
53
|
"access": "public"
|
|
53
54
|
},
|
|
54
55
|
"repository": {
|