harnesstap 1.2.0 → 1.3.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/README.md +28 -15
- package/dist/apply-QSS4242W.js +67 -0
- package/dist/apply-QSS4242W.js.map +1 -0
- package/dist/approve-CNYQY6DC.js +181 -0
- package/dist/approve-CNYQY6DC.js.map +1 -0
- package/dist/audit-V4SUV7KA.js +434 -0
- package/dist/audit-V4SUV7KA.js.map +1 -0
- package/dist/auth-63FOHIQ3.js +220 -0
- package/dist/auth-63FOHIQ3.js.map +1 -0
- package/dist/bin.js +166 -0
- package/dist/bin.js.map +1 -0
- package/dist/chunk-2H7UOFLK.js +11 -0
- package/dist/chunk-2H7UOFLK.js.map +1 -0
- package/dist/chunk-2NE3QYMP.js +103 -0
- package/dist/chunk-2NE3QYMP.js.map +1 -0
- package/dist/chunk-2P2EOYEW.js +1140 -0
- package/dist/chunk-2P2EOYEW.js.map +1 -0
- package/dist/chunk-37E5M4JX.js +34 -0
- package/dist/chunk-37E5M4JX.js.map +1 -0
- package/dist/chunk-37LQQWMF.js +496 -0
- package/dist/chunk-37LQQWMF.js.map +1 -0
- package/dist/chunk-3FIWOI3H.js +98 -0
- package/dist/chunk-3FIWOI3H.js.map +1 -0
- package/dist/chunk-3PGC6OA3.js +540 -0
- package/dist/chunk-3PGC6OA3.js.map +1 -0
- package/dist/chunk-4IHKBIY3.js +118 -0
- package/dist/chunk-4IHKBIY3.js.map +1 -0
- package/dist/chunk-4ZUBRLSP.js +17 -0
- package/dist/chunk-4ZUBRLSP.js.map +1 -0
- package/dist/chunk-5F3LNDZG.js +9 -0
- package/dist/chunk-5F3LNDZG.js.map +1 -0
- package/dist/chunk-5TXI6BI2.js +1359 -0
- package/dist/chunk-5TXI6BI2.js.map +1 -0
- package/dist/chunk-6P5IO4BX.js +235 -0
- package/dist/chunk-6P5IO4BX.js.map +1 -0
- package/dist/chunk-ABXUKHAU.js +571 -0
- package/dist/chunk-ABXUKHAU.js.map +1 -0
- package/dist/chunk-AOUDSNRK.js +1357 -0
- package/dist/chunk-AOUDSNRK.js.map +1 -0
- package/dist/chunk-BNDJJAEI.js +311 -0
- package/dist/chunk-BNDJJAEI.js.map +1 -0
- package/dist/chunk-C2IWSFF5.js +818 -0
- package/dist/chunk-C2IWSFF5.js.map +1 -0
- package/dist/chunk-CHQGE2HF.js +283 -0
- package/dist/chunk-CHQGE2HF.js.map +1 -0
- package/dist/chunk-DEJLP7QJ.js +681 -0
- package/dist/chunk-DEJLP7QJ.js.map +1 -0
- package/dist/chunk-DJ6FN6EW.js +532 -0
- package/dist/chunk-DJ6FN6EW.js.map +1 -0
- package/dist/chunk-E4WRTRMH.js +1173 -0
- package/dist/chunk-E4WRTRMH.js.map +1 -0
- package/dist/chunk-E5QXNU3K.js +238 -0
- package/dist/chunk-E5QXNU3K.js.map +1 -0
- package/dist/chunk-EMTBGOR3.js +2959 -0
- package/dist/chunk-EMTBGOR3.js.map +1 -0
- package/dist/chunk-FFWYIGQ4.js +18 -0
- package/dist/chunk-FFWYIGQ4.js.map +1 -0
- package/dist/chunk-I6XFZLTJ.js +9 -0
- package/dist/chunk-I6XFZLTJ.js.map +1 -0
- package/dist/chunk-IHWAOIAU.js +172 -0
- package/dist/chunk-IHWAOIAU.js.map +1 -0
- package/dist/chunk-IHZUYG66.js +583 -0
- package/dist/chunk-IHZUYG66.js.map +1 -0
- package/dist/chunk-JQOKQKQT.js +158 -0
- package/dist/chunk-JQOKQKQT.js.map +1 -0
- package/dist/chunk-JRFUTIEH.js +426 -0
- package/dist/chunk-JRFUTIEH.js.map +1 -0
- package/dist/chunk-KCBI6JQC.js +115 -0
- package/dist/chunk-KCBI6JQC.js.map +1 -0
- package/dist/chunk-KDUQMINL.js +60 -0
- package/dist/chunk-KDUQMINL.js.map +1 -0
- package/dist/chunk-KLR2DURP.js +656 -0
- package/dist/chunk-KLR2DURP.js.map +1 -0
- package/dist/chunk-KRI4R7EM.js +25 -0
- package/dist/chunk-KRI4R7EM.js.map +1 -0
- package/dist/chunk-LYQMK6SV.js +87 -0
- package/dist/chunk-LYQMK6SV.js.map +1 -0
- package/dist/chunk-MK3Q37ZN.js +183 -0
- package/dist/chunk-MK3Q37ZN.js.map +1 -0
- package/dist/chunk-MSGAGV7B.js +346 -0
- package/dist/chunk-MSGAGV7B.js.map +1 -0
- package/dist/chunk-MZQRSERO.js +430 -0
- package/dist/chunk-MZQRSERO.js.map +1 -0
- package/dist/chunk-N3WIJXXM.js +691 -0
- package/dist/chunk-N3WIJXXM.js.map +1 -0
- package/dist/chunk-NAGAJ5UM.js +145 -0
- package/dist/chunk-NAGAJ5UM.js.map +1 -0
- package/dist/chunk-NFYPBTKO.js +302 -0
- package/dist/chunk-NFYPBTKO.js.map +1 -0
- package/dist/chunk-NPO2IG6G.js +491 -0
- package/dist/chunk-NPO2IG6G.js.map +1 -0
- package/dist/chunk-OS6NUIBJ.js +38 -0
- package/dist/chunk-OS6NUIBJ.js.map +1 -0
- package/dist/chunk-PFUK3HJ4.js +296 -0
- package/dist/chunk-PFUK3HJ4.js.map +1 -0
- package/dist/chunk-PMQ55GDB.js +115 -0
- package/dist/chunk-PMQ55GDB.js.map +1 -0
- package/dist/chunk-QIVE2YFJ.js +514 -0
- package/dist/chunk-QIVE2YFJ.js.map +1 -0
- package/dist/chunk-QKXD3EUF.js +691 -0
- package/dist/chunk-QKXD3EUF.js.map +1 -0
- package/dist/chunk-RNQYUWF6.js +32 -0
- package/dist/chunk-RNQYUWF6.js.map +1 -0
- package/dist/chunk-S2E4SSQV.js +41 -0
- package/dist/chunk-S2E4SSQV.js.map +1 -0
- package/dist/chunk-SN4BXX3B.js +186 -0
- package/dist/chunk-SN4BXX3B.js.map +1 -0
- package/dist/chunk-SNVAMWB7.js +40 -0
- package/dist/chunk-SNVAMWB7.js.map +1 -0
- package/dist/chunk-T5VRREN4.js +696 -0
- package/dist/chunk-T5VRREN4.js.map +1 -0
- package/dist/chunk-TKBMHZTS.js +10945 -0
- package/dist/chunk-TKBMHZTS.js.map +1 -0
- package/dist/chunk-TNJPTUE4.js +35 -0
- package/dist/chunk-TNJPTUE4.js.map +1 -0
- package/dist/chunk-TQ2NA4Z4.js +24 -0
- package/dist/chunk-TQ2NA4Z4.js.map +1 -0
- package/dist/chunk-TXXDMDPN.js +998 -0
- package/dist/chunk-TXXDMDPN.js.map +1 -0
- package/dist/chunk-UWXUBU7V.js +184 -0
- package/dist/chunk-UWXUBU7V.js.map +1 -0
- package/dist/chunk-UYRK2H24.js +141 -0
- package/dist/chunk-UYRK2H24.js.map +1 -0
- package/dist/chunk-V4IXIM3C.js +806 -0
- package/dist/chunk-V4IXIM3C.js.map +1 -0
- package/dist/chunk-VFHVXXP4.js +6438 -0
- package/dist/chunk-VFHVXXP4.js.map +1 -0
- package/dist/chunk-VQVUJYYY.js +244 -0
- package/dist/chunk-VQVUJYYY.js.map +1 -0
- package/dist/chunk-VZQG2JDV.js +9 -0
- package/dist/chunk-VZQG2JDV.js.map +1 -0
- package/dist/chunk-W7HQ5X3S.js +610 -0
- package/dist/chunk-W7HQ5X3S.js.map +1 -0
- package/dist/chunk-WMSQAFK5.js +65 -0
- package/dist/chunk-WMSQAFK5.js.map +1 -0
- package/dist/chunk-WMYTBJPB.js +364 -0
- package/dist/chunk-WMYTBJPB.js.map +1 -0
- package/dist/chunk-WNLFNCOH.js +7795 -0
- package/dist/chunk-WNLFNCOH.js.map +1 -0
- package/dist/chunk-WRX7CB2M.js +6448 -0
- package/dist/chunk-WRX7CB2M.js.map +1 -0
- package/dist/chunk-XGTTOO4R.js +84 -0
- package/dist/chunk-XGTTOO4R.js.map +1 -0
- package/dist/chunk-YSXRBUR4.js +682 -0
- package/dist/chunk-YSXRBUR4.js.map +1 -0
- package/dist/chunk-YTC2EG64.js +1759 -0
- package/dist/chunk-YTC2EG64.js.map +1 -0
- package/dist/compile-J3UGQSS3.js +161 -0
- package/dist/compile-J3UGQSS3.js.map +1 -0
- package/dist/config-5BPSZND3.js +438 -0
- package/dist/config-5BPSZND3.js.map +1 -0
- package/dist/doctor-BVFKLJVO.js +111 -0
- package/dist/doctor-BVFKLJVO.js.map +1 -0
- package/dist/environment-3RI5H32O.js +2745 -0
- package/dist/environment-3RI5H32O.js.map +1 -0
- package/dist/github-YFJQVH5K.js +114 -0
- package/dist/github-YFJQVH5K.js.map +1 -0
- package/dist/harness-ECGHPEKA.js +746 -0
- package/dist/harness-ECGHPEKA.js.map +1 -0
- package/dist/help-ELPNPPEM.js +2079 -0
- package/dist/help-ELPNPPEM.js.map +1 -0
- package/dist/help-UL5XLY3I.js +1892 -0
- package/dist/help-UL5XLY3I.js.map +1 -0
- package/dist/index.d.ts +164 -1
- package/dist/index.js +50 -59246
- package/dist/index.js.map +1 -1
- package/dist/init-UJQTDHW7.js +873 -0
- package/dist/init-UJQTDHW7.js.map +1 -0
- package/dist/lock-XUMJ63NZ.js +455 -0
- package/dist/lock-XUMJ63NZ.js.map +1 -0
- package/dist/marketplace-ZUMOLVXE.js +495 -0
- package/dist/marketplace-ZUMOLVXE.js.map +1 -0
- package/dist/mcp-RZA5O2ND.js +202 -0
- package/dist/mcp-RZA5O2ND.js.map +1 -0
- package/dist/migrate-CYQI2FH6.js +1043 -0
- package/dist/migrate-CYQI2FH6.js.map +1 -0
- package/dist/open-AWOAWLKO.js +32 -0
- package/dist/open-AWOAWLKO.js.map +1 -0
- package/dist/pack-2QD5ZUIO.js +99 -0
- package/dist/pack-2QD5ZUIO.js.map +1 -0
- package/dist/plugin-GQSSSFX4.js +64 -0
- package/dist/plugin-GQSSSFX4.js.map +1 -0
- package/dist/plugin-from-project-SIQUFYIO.js +16 -0
- package/dist/plugin-from-project-SIQUFYIO.js.map +1 -0
- package/dist/policy-CT4JRCJI.js +105 -0
- package/dist/policy-CT4JRCJI.js.map +1 -0
- package/dist/profile-4JQ6LECP.js +1886 -0
- package/dist/profile-4JQ6LECP.js.map +1 -0
- package/dist/project-JG7QWXRG.js +1392 -0
- package/dist/project-JG7QWXRG.js.map +1 -0
- package/dist/resource-QRMR6CSD.js +555 -0
- package/dist/resource-QRMR6CSD.js.map +1 -0
- package/dist/version-LZ5POOXY.js +17 -0
- package/dist/version-LZ5POOXY.js.map +1 -0
- package/package.json +21 -14
- package/schemas/ap-package.v1.json +36 -0
- package/schemas/fixtures/catalog-missing-schema.ap.json +13 -0
- package/schemas/fixtures/confidence.ap.json +13 -0
- package/schemas/fixtures/context7.ap.json +13 -0
- package/schemas/fixtures/minimal-with-schema.ap.json +13 -0
- package/schemas/fixtures/superpowers.ap.json +13 -0
- package/schemas/fixtures/third-party-skills.ap.json +13 -0
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
// src/services/plugin-resource-mode.ts
|
|
2
|
+
var DEFAULT_PLUGIN_RESOURCE_MODE = "symlink";
|
|
3
|
+
function isPluginResourceMode(value) {
|
|
4
|
+
return value === "symlink" || value === "copy" || value === "clone";
|
|
5
|
+
}
|
|
6
|
+
function parsePluginResourceMode(value) {
|
|
7
|
+
if (isPluginResourceMode(value)) return value;
|
|
8
|
+
throw new Error(
|
|
9
|
+
`Invalid plugin resource mode: ${value}. Use symlink, copy, or clone.`
|
|
10
|
+
);
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/config/settings.ts
|
|
14
|
+
import { existsSync, mkdirSync, readFileSync, writeFileSync } from "fs";
|
|
15
|
+
import { join } from "path";
|
|
16
|
+
var VALID_PLATFORMS = /* @__PURE__ */ new Set([
|
|
17
|
+
"claude-code",
|
|
18
|
+
"cursor",
|
|
19
|
+
"goose",
|
|
20
|
+
"copilot-cli"
|
|
21
|
+
]);
|
|
22
|
+
var DEFAULT_MARKETPLACE_REFRESH_MAX_AGE_MINUTES = 60;
|
|
23
|
+
function marketplaceRefreshMaxAgeMs(minutes) {
|
|
24
|
+
return minutes * 60 * 1e3;
|
|
25
|
+
}
|
|
26
|
+
var DEFAULTS = {
|
|
27
|
+
plugins: {
|
|
28
|
+
refreshMaxAgeHours: 24,
|
|
29
|
+
marketplaceRefreshMaxAgeMinutes: DEFAULT_MARKETPLACE_REFRESH_MAX_AGE_MINUTES,
|
|
30
|
+
marketplaces: []
|
|
31
|
+
},
|
|
32
|
+
pluginVersionHistoryLimit: 10,
|
|
33
|
+
harnessSync: { pluginResources: DEFAULT_PLUGIN_RESOURCE_MODE }
|
|
34
|
+
};
|
|
35
|
+
function isPluginMarketplacePlatform(value) {
|
|
36
|
+
return typeof value === "string" && VALID_PLATFORMS.has(value);
|
|
37
|
+
}
|
|
38
|
+
function parseTrackedBranches(value) {
|
|
39
|
+
if (!Array.isArray(value)) return [];
|
|
40
|
+
const seen = /* @__PURE__ */ new Set();
|
|
41
|
+
const branches = [];
|
|
42
|
+
for (const item of value) {
|
|
43
|
+
if (typeof item !== "string") continue;
|
|
44
|
+
const trimmed = item.trim();
|
|
45
|
+
if (!trimmed || seen.has(trimmed)) continue;
|
|
46
|
+
seen.add(trimmed);
|
|
47
|
+
branches.push(trimmed);
|
|
48
|
+
}
|
|
49
|
+
return branches;
|
|
50
|
+
}
|
|
51
|
+
function settingsPath(harnesstapDir) {
|
|
52
|
+
return existsSync(join(harnesstapDir, "config.jsonc")) ? join(harnesstapDir, "config.jsonc") : join(harnesstapDir, "config.json");
|
|
53
|
+
}
|
|
54
|
+
function parseMarketplaces(value) {
|
|
55
|
+
if (!Array.isArray(value)) return [];
|
|
56
|
+
const marketplaces = [];
|
|
57
|
+
for (const row of value) {
|
|
58
|
+
if (typeof row !== "object" || row === null) continue;
|
|
59
|
+
const record = row;
|
|
60
|
+
const name = record.name;
|
|
61
|
+
const url = record.url;
|
|
62
|
+
const platforms = record.platforms;
|
|
63
|
+
if (typeof name !== "string") continue;
|
|
64
|
+
const trimmedName = name.trim();
|
|
65
|
+
if (trimmedName.length === 0) continue;
|
|
66
|
+
if (typeof url !== "string") continue;
|
|
67
|
+
const trimmedUrl = url.trim();
|
|
68
|
+
if (trimmedUrl.length === 0) continue;
|
|
69
|
+
if (!Array.isArray(platforms)) continue;
|
|
70
|
+
const parsedPlatforms = platforms.filter(isPluginMarketplacePlatform);
|
|
71
|
+
if (parsedPlatforms.length === 0) continue;
|
|
72
|
+
const trackedBranches = parseTrackedBranches(record.trackedBranches);
|
|
73
|
+
marketplaces.push({
|
|
74
|
+
name: trimmedName,
|
|
75
|
+
url: trimmedUrl,
|
|
76
|
+
platforms: parsedPlatforms,
|
|
77
|
+
...trackedBranches.length > 0 ? { trackedBranches } : {}
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
return marketplaces;
|
|
81
|
+
}
|
|
82
|
+
function parseJsonc(content) {
|
|
83
|
+
let normalized = "";
|
|
84
|
+
let inString = false;
|
|
85
|
+
let stringQuote = '"';
|
|
86
|
+
let escaping = false;
|
|
87
|
+
let inLineComment = false;
|
|
88
|
+
let inBlockComment = false;
|
|
89
|
+
for (let index = 0; index < content.length; index++) {
|
|
90
|
+
const char = content[index];
|
|
91
|
+
const nextChar = content[index + 1];
|
|
92
|
+
if (inLineComment) {
|
|
93
|
+
if (char === "\n") {
|
|
94
|
+
inLineComment = false;
|
|
95
|
+
normalized += char;
|
|
96
|
+
}
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
if (inBlockComment) {
|
|
100
|
+
if (char === "*" && nextChar === "/") {
|
|
101
|
+
inBlockComment = false;
|
|
102
|
+
index++;
|
|
103
|
+
}
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
if (inString) {
|
|
107
|
+
normalized += char;
|
|
108
|
+
if (escaping) {
|
|
109
|
+
escaping = false;
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
if (char === "\\") {
|
|
113
|
+
escaping = true;
|
|
114
|
+
continue;
|
|
115
|
+
}
|
|
116
|
+
if (char === stringQuote) {
|
|
117
|
+
inString = false;
|
|
118
|
+
}
|
|
119
|
+
continue;
|
|
120
|
+
}
|
|
121
|
+
if ((char === '"' || char === "'") && !inString) {
|
|
122
|
+
inString = true;
|
|
123
|
+
stringQuote = char;
|
|
124
|
+
normalized += char;
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
if (char === "/" && nextChar === "/") {
|
|
128
|
+
inLineComment = true;
|
|
129
|
+
index++;
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
if (char === "/" && nextChar === "*") {
|
|
133
|
+
inBlockComment = true;
|
|
134
|
+
index++;
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
if (char === ",") {
|
|
138
|
+
let lookahead = index + 1;
|
|
139
|
+
while (lookahead < content.length) {
|
|
140
|
+
const lookaheadChar = content[lookahead];
|
|
141
|
+
const lookaheadNextChar = content[lookahead + 1];
|
|
142
|
+
if (lookaheadChar !== void 0 && /\s/.test(lookaheadChar)) {
|
|
143
|
+
lookahead++;
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
if (lookaheadChar === "/" && lookaheadNextChar === "/") {
|
|
147
|
+
lookahead += 2;
|
|
148
|
+
while (lookahead < content.length && content[lookahead] !== "\n") {
|
|
149
|
+
lookahead++;
|
|
150
|
+
}
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
if (lookaheadChar === "/" && lookaheadNextChar === "*") {
|
|
154
|
+
lookahead += 2;
|
|
155
|
+
while (lookahead < content.length && !(content[lookahead] === "*" && content[lookahead + 1] === "/")) {
|
|
156
|
+
lookahead++;
|
|
157
|
+
}
|
|
158
|
+
lookahead += 2;
|
|
159
|
+
continue;
|
|
160
|
+
}
|
|
161
|
+
if (lookaheadChar === "}" || lookaheadChar === "]") {
|
|
162
|
+
break;
|
|
163
|
+
}
|
|
164
|
+
normalized += char;
|
|
165
|
+
break;
|
|
166
|
+
}
|
|
167
|
+
if (lookahead >= content.length) {
|
|
168
|
+
normalized += char;
|
|
169
|
+
}
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
normalized += char;
|
|
173
|
+
}
|
|
174
|
+
return JSON.parse(normalized);
|
|
175
|
+
}
|
|
176
|
+
function loadSettings(harnesstapDir) {
|
|
177
|
+
const path = settingsPath(harnesstapDir);
|
|
178
|
+
if (!existsSync(path)) return DEFAULTS;
|
|
179
|
+
try {
|
|
180
|
+
const raw = parseJsonc(readFileSync(path, "utf-8"));
|
|
181
|
+
const hours = raw.plugins?.refreshMaxAgeHours;
|
|
182
|
+
const marketplaceMinutes = raw.plugins?.marketplaceRefreshMaxAgeMinutes;
|
|
183
|
+
const limit = raw.pluginVersionHistoryLimit;
|
|
184
|
+
const pluginResources = raw.harnessSync?.pluginResources;
|
|
185
|
+
return {
|
|
186
|
+
plugins: {
|
|
187
|
+
refreshMaxAgeHours: typeof hours === "number" && hours > 0 ? hours : DEFAULTS.plugins.refreshMaxAgeHours,
|
|
188
|
+
marketplaceRefreshMaxAgeMinutes: typeof marketplaceMinutes === "number" && marketplaceMinutes > 0 ? marketplaceMinutes : DEFAULTS.plugins.marketplaceRefreshMaxAgeMinutes,
|
|
189
|
+
marketplaces: parseMarketplaces(raw.plugins?.marketplaces)
|
|
190
|
+
},
|
|
191
|
+
pluginVersionHistoryLimit: typeof limit === "number" && Number.isInteger(limit) && limit >= 1 ? limit : DEFAULTS.pluginVersionHistoryLimit,
|
|
192
|
+
harnessSync: {
|
|
193
|
+
pluginResources: isPluginResourceMode(pluginResources) ? pluginResources : DEFAULTS.harnessSync.pluginResources
|
|
194
|
+
}
|
|
195
|
+
};
|
|
196
|
+
} catch {
|
|
197
|
+
return DEFAULTS;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
function readToolkitConfigRecord(harnesstapDir, path = settingsPath(harnesstapDir)) {
|
|
201
|
+
if (!existsSync(path)) {
|
|
202
|
+
return {};
|
|
203
|
+
}
|
|
204
|
+
try {
|
|
205
|
+
const parsed = parseJsonc(readFileSync(path, "utf-8"));
|
|
206
|
+
if (parsed && typeof parsed === "object" && !Array.isArray(parsed)) {
|
|
207
|
+
return parsed;
|
|
208
|
+
}
|
|
209
|
+
return {};
|
|
210
|
+
} catch {
|
|
211
|
+
return {};
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function writeToolkitConfigRecord(harnesstapDir, record, path = settingsPath(harnesstapDir)) {
|
|
215
|
+
mkdirSync(harnesstapDir, { recursive: true });
|
|
216
|
+
writeFileSync(path, `${JSON.stringify(record, null, 2)}
|
|
217
|
+
`, "utf-8");
|
|
218
|
+
}
|
|
219
|
+
function saveSettings(harnesstapDir, settings) {
|
|
220
|
+
const path = settingsPath(harnesstapDir);
|
|
221
|
+
const existing = readToolkitConfigRecord(harnesstapDir, path);
|
|
222
|
+
writeToolkitConfigRecord(
|
|
223
|
+
harnesstapDir,
|
|
224
|
+
{
|
|
225
|
+
...existing,
|
|
226
|
+
plugins: settings.plugins,
|
|
227
|
+
pluginVersionHistoryLimit: settings.pluginVersionHistoryLimit,
|
|
228
|
+
harnessSync: settings.harnessSync
|
|
229
|
+
},
|
|
230
|
+
path
|
|
231
|
+
);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export {
|
|
235
|
+
DEFAULT_PLUGIN_RESOURCE_MODE,
|
|
236
|
+
parsePluginResourceMode,
|
|
237
|
+
DEFAULT_MARKETPLACE_REFRESH_MAX_AGE_MINUTES,
|
|
238
|
+
marketplaceRefreshMaxAgeMs,
|
|
239
|
+
parseTrackedBranches,
|
|
240
|
+
parseJsonc,
|
|
241
|
+
loadSettings,
|
|
242
|
+
saveSettings
|
|
243
|
+
};
|
|
244
|
+
//# sourceMappingURL=chunk-VQVUJYYY.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/plugin-resource-mode.ts","../src/config/settings.ts"],"sourcesContent":["export const PLUGIN_RESOURCE_MODES = [\"symlink\", \"copy\", \"clone\"] as const;\n\nexport type PluginResourceMode = (typeof PLUGIN_RESOURCE_MODES)[number];\n\nexport const DEFAULT_PLUGIN_RESOURCE_MODE: PluginResourceMode = \"symlink\";\n\nexport function isPluginResourceMode(value: unknown): value is PluginResourceMode {\n return value === \"symlink\" || value === \"copy\" || value === \"clone\";\n}\n\nexport function parsePluginResourceMode(\n value: string | undefined,\n): PluginResourceMode {\n if (isPluginResourceMode(value)) return value;\n throw new Error(\n `Invalid plugin resource mode: ${value}. Use symlink, copy, or clone.`,\n );\n}\n","import { existsSync, mkdirSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport {\n DEFAULT_PLUGIN_RESOURCE_MODE,\n isPluginResourceMode,\n type PluginResourceMode,\n} from \"../services/plugin-resource-mode.js\";\n\nexport type PluginMarketplacePlatform =\n | \"claude-code\"\n | \"cursor\"\n | \"goose\"\n | \"copilot-cli\";\n\nexport interface PluginMarketplaceEntry {\n name: string;\n url: string;\n platforms: PluginMarketplacePlatform[];\n /** Extra git branches to catalog. Empty/omitted tracks only the default branch. */\n trackedBranches?: string[];\n}\n\nexport interface HarnesstapSettings {\n plugins: {\n refreshMaxAgeHours: number;\n marketplaceRefreshMaxAgeMinutes: number;\n marketplaces: PluginMarketplaceEntry[];\n };\n pluginVersionHistoryLimit: number;\n harnessSync: {\n pluginResources: PluginResourceMode;\n };\n}\n\nconst VALID_PLATFORMS = new Set<PluginMarketplacePlatform>([\n \"claude-code\",\n \"cursor\",\n \"goose\",\n \"copilot-cli\",\n]);\n\nexport const DEFAULT_MARKETPLACE_REFRESH_MAX_AGE_MINUTES = 60;\n\nexport function marketplaceRefreshMaxAgeMs(minutes: number): number {\n return minutes * 60 * 1000;\n}\n\nconst DEFAULTS: HarnesstapSettings = {\n plugins: {\n refreshMaxAgeHours: 24,\n marketplaceRefreshMaxAgeMinutes: DEFAULT_MARKETPLACE_REFRESH_MAX_AGE_MINUTES,\n marketplaces: [],\n },\n pluginVersionHistoryLimit: 10,\n harnessSync: { pluginResources: DEFAULT_PLUGIN_RESOURCE_MODE },\n};\n\nfunction isPluginMarketplacePlatform(\n value: unknown,\n): value is PluginMarketplacePlatform {\n return (\n typeof value === \"string\" &&\n VALID_PLATFORMS.has(value as PluginMarketplacePlatform)\n );\n}\n\nexport function parseTrackedBranches(value: unknown): string[] {\n if (!Array.isArray(value)) return [];\n\n const seen = new Set<string>();\n const branches: string[] = [];\n for (const item of value) {\n if (typeof item !== \"string\") continue;\n const trimmed = item.trim();\n if (!trimmed || seen.has(trimmed)) continue;\n seen.add(trimmed);\n branches.push(trimmed);\n }\n return branches;\n}\n\nexport function settingsPath(harnesstapDir: string): string {\n return existsSync(join(harnesstapDir, \"config.jsonc\"))\n ? join(harnesstapDir, \"config.jsonc\")\n : join(harnesstapDir, \"config.json\");\n}\n\nexport function parseMarketplaces(value: unknown): PluginMarketplaceEntry[] {\n if (!Array.isArray(value)) return [];\n\n const marketplaces: PluginMarketplaceEntry[] = [];\n for (const row of value) {\n if (typeof row !== \"object\" || row === null) continue;\n\n const record = row as Record<string, unknown>;\n const name = record.name;\n const url = record.url;\n const platforms = record.platforms;\n\n if (typeof name !== \"string\") continue;\n const trimmedName = name.trim();\n if (trimmedName.length === 0) continue;\n if (typeof url !== \"string\") continue;\n const trimmedUrl = url.trim();\n if (trimmedUrl.length === 0) continue;\n if (!Array.isArray(platforms)) continue;\n\n const parsedPlatforms = platforms.filter(isPluginMarketplacePlatform);\n if (parsedPlatforms.length === 0) continue;\n\n const trackedBranches = parseTrackedBranches(record.trackedBranches);\n marketplaces.push({\n name: trimmedName,\n url: trimmedUrl,\n platforms: parsedPlatforms,\n ...(trackedBranches.length > 0 ? { trackedBranches } : {}),\n });\n }\n\n return marketplaces;\n}\n\nexport function parseJsonc(content: string): unknown {\n let normalized = \"\";\n let inString = false;\n let stringQuote = '\"';\n let escaping = false;\n let inLineComment = false;\n let inBlockComment = false;\n\n for (let index = 0; index < content.length; index++) {\n const char = content[index];\n const nextChar = content[index + 1];\n\n if (inLineComment) {\n if (char === \"\\n\") {\n inLineComment = false;\n normalized += char;\n }\n continue;\n }\n\n if (inBlockComment) {\n if (char === \"*\" && nextChar === \"/\") {\n inBlockComment = false;\n index++;\n }\n continue;\n }\n\n if (inString) {\n normalized += char;\n if (escaping) {\n escaping = false;\n continue;\n }\n if (char === \"\\\\\") {\n escaping = true;\n continue;\n }\n if (char === stringQuote) {\n inString = false;\n }\n continue;\n }\n\n if ((char === '\"' || char === \"'\") && !inString) {\n inString = true;\n stringQuote = char;\n normalized += char;\n continue;\n }\n\n if (char === \"/\" && nextChar === \"/\") {\n inLineComment = true;\n index++;\n continue;\n }\n\n if (char === \"/\" && nextChar === \"*\") {\n inBlockComment = true;\n index++;\n continue;\n }\n\n if (char === \",\") {\n let lookahead = index + 1;\n while (lookahead < content.length) {\n const lookaheadChar = content[lookahead];\n const lookaheadNextChar = content[lookahead + 1];\n\n if (lookaheadChar !== undefined && /\\s/.test(lookaheadChar)) {\n lookahead++;\n continue;\n }\n\n if (lookaheadChar === \"/\" && lookaheadNextChar === \"/\") {\n lookahead += 2;\n while (lookahead < content.length && content[lookahead] !== \"\\n\") {\n lookahead++;\n }\n continue;\n }\n\n if (lookaheadChar === \"/\" && lookaheadNextChar === \"*\") {\n lookahead += 2;\n while (\n lookahead < content.length &&\n !(content[lookahead] === \"*\" && content[lookahead + 1] === \"/\")\n ) {\n lookahead++;\n }\n lookahead += 2;\n continue;\n }\n\n if (lookaheadChar === \"}\" || lookaheadChar === \"]\") {\n break;\n }\n\n normalized += char;\n break;\n }\n\n if (lookahead >= content.length) {\n normalized += char;\n }\n continue;\n }\n\n normalized += char;\n }\n\n return JSON.parse(normalized);\n}\n\nexport function loadSettings(harnesstapDir: string): HarnesstapSettings {\n const path = settingsPath(harnesstapDir);\n if (!existsSync(path)) return DEFAULTS;\n try {\n const raw = parseJsonc(readFileSync(path, \"utf-8\")) as Partial<HarnesstapSettings> & {\n harnessSync?: { pluginResources?: unknown };\n };\n const hours = raw.plugins?.refreshMaxAgeHours;\n const marketplaceMinutes = raw.plugins?.marketplaceRefreshMaxAgeMinutes;\n const limit = raw.pluginVersionHistoryLimit;\n const pluginResources = raw.harnessSync?.pluginResources;\n return {\n plugins: {\n refreshMaxAgeHours:\n typeof hours === \"number\" && hours > 0\n ? hours\n : DEFAULTS.plugins.refreshMaxAgeHours,\n marketplaceRefreshMaxAgeMinutes:\n typeof marketplaceMinutes === \"number\" && marketplaceMinutes > 0\n ? marketplaceMinutes\n : DEFAULTS.plugins.marketplaceRefreshMaxAgeMinutes,\n marketplaces: parseMarketplaces(raw.plugins?.marketplaces),\n },\n pluginVersionHistoryLimit:\n typeof limit === \"number\" && Number.isInteger(limit) && limit >= 1\n ? limit\n : DEFAULTS.pluginVersionHistoryLimit,\n harnessSync: {\n pluginResources: isPluginResourceMode(pluginResources)\n ? pluginResources\n : DEFAULTS.harnessSync.pluginResources,\n },\n };\n } catch {\n return DEFAULTS;\n }\n}\n\nexport function readToolkitConfigRecord(\n harnesstapDir: string,\n path = settingsPath(harnesstapDir),\n): Record<string, unknown> {\n if (!existsSync(path)) {\n return {};\n }\n try {\n const parsed = parseJsonc(readFileSync(path, \"utf-8\"));\n if (parsed && typeof parsed === \"object\" && !Array.isArray(parsed)) {\n return parsed as Record<string, unknown>;\n }\n return {};\n } catch {\n return {};\n }\n}\n\nexport function writeToolkitConfigRecord(\n harnesstapDir: string,\n record: Record<string, unknown>,\n path = settingsPath(harnesstapDir),\n): void {\n mkdirSync(harnesstapDir, { recursive: true });\n writeFileSync(path, `${JSON.stringify(record, null, 2)}\\n`, \"utf-8\");\n}\n\nexport function saveSettings(\n harnesstapDir: string,\n settings: HarnesstapSettings,\n): void {\n const path = settingsPath(harnesstapDir);\n const existing = readToolkitConfigRecord(harnesstapDir, path);\n writeToolkitConfigRecord(\n harnesstapDir,\n {\n ...existing,\n plugins: settings.plugins,\n pluginVersionHistoryLimit: settings.pluginVersionHistoryLimit,\n harnessSync: settings.harnessSync,\n },\n path,\n );\n}\n"],"mappings":";AAIO,IAAM,+BAAmD;AAEzD,SAAS,qBAAqB,OAA6C;AAChF,SAAO,UAAU,aAAa,UAAU,UAAU,UAAU;AAC9D;AAEO,SAAS,wBACd,OACoB;AACpB,MAAI,qBAA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AA,MACH,SAAS,SAAS;AAAA,MAClB,2BAA2B,SAAS;AAAA,MACpC,aAAa,SAAS;AAAA,IACxB;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// src/services/project-config-messages.ts
|
|
2
|
+
var MISSING_PROJECT_CONFIG_MESSAGE = "No project config found. Run `ht config init` to create `apm.yml`.";
|
|
3
|
+
var PROJECT_CONFIG_EXISTS_MESSAGE = "Project config already exists. Pass --force to overwrite, or edit `apm.yml` directly.";
|
|
4
|
+
|
|
5
|
+
export {
|
|
6
|
+
MISSING_PROJECT_CONFIG_MESSAGE,
|
|
7
|
+
PROJECT_CONFIG_EXISTS_MESSAGE
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=chunk-VZQG2JDV.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/services/project-config-messages.ts"],"sourcesContent":["export const MISSING_PROJECT_CONFIG_MESSAGE =\n \"No project config found. Run `ht config init` to create `apm.yml`.\";\n\nexport const PROJECT_CONFIG_EXISTS_MESSAGE =\n \"Project config already exists. Pass --force to overwrite, or edit `apm.yml` directly.\";\n"],"mappings":";AAAO,IAAM,iCACX;AAEK,IAAM,gCACX;","names":[]}
|