dsh-plugin-toolkit 0.20.16 → 0.20.17
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/CHANGELOG.md +19 -0
- package/README.md +9 -0
- package/lib/audit.mjs +129 -75
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,22 @@
|
|
|
1
|
+
## 0.20.17
|
|
2
|
+
|
|
3
|
+
- **`audit` reports a declared bundle whose folder is gone.** When a package
|
|
4
|
+
name stayed in `dsh.profile.bundles` but its `node_modules/<name>` folder had
|
|
5
|
+
been removed, the install scan never saw the package and `audit --home`
|
|
6
|
+
printed only its healthy siblings, so the command exited `0` and hid the
|
|
7
|
+
reason the loader could not mount it. The scan now starts from the profile's
|
|
8
|
+
declared bundles and prints a `missing` row with an `install` failure naming
|
|
9
|
+
the absent `node_modules/<name>` path; the valid siblings are still listed
|
|
10
|
+
and the command exits `1`. A package that is absent but undeclared is still
|
|
11
|
+
ignored, so ordinary dependencies do not appear. A regression test pins the
|
|
12
|
+
module result and the spawned CLI exit code in both directions: the declared
|
|
13
|
+
missing bundle exits `1`, and the same home with the name removed from the
|
|
14
|
+
profile exits `0` without printing it. A checked-in home at
|
|
15
|
+
`test/fixtures/missing-declared-bundle` also keeps the minimal case — one
|
|
16
|
+
declared name and no `node_modules` directory at all — reproducible through
|
|
17
|
+
`audit --home`, so the scan cannot fall back to "nothing installed" and exit
|
|
18
|
+
clean again.
|
|
19
|
+
|
|
1
20
|
## 0.20.16
|
|
2
21
|
|
|
3
22
|
- **`doctor` names a root export that cannot be loaded.** A package whose
|
package/README.md
CHANGED
|
@@ -324,6 +324,15 @@ damaged `package.json` in a package that is neither in `dsh.profile.bundles` nor
|
|
|
324
324
|
readable enough to expose a `dsh` field is still an ordinary dependency and is
|
|
325
325
|
skipped, so one broken transitive install does not fail every audit.
|
|
326
326
|
|
|
327
|
+
A declared bundle can also be missing entirely. If a name stays in
|
|
328
|
+
`dsh.profile.bundles` after its `node_modules/<name>` folder is removed (an
|
|
329
|
+
interrupted install, or a package deleted by hand), `audit` prints a `missing`
|
|
330
|
+
row with an `install` failure naming the absent folder and exits `1`, while
|
|
331
|
+
still listing the healthy plugins on the same run. An absent package that the
|
|
332
|
+
profile never declared is not an install record, so it is not invented in the
|
|
333
|
+
report; a regression test removes the name from the profile and requires the
|
|
334
|
+
shipped CLI to exit `0` without printing it.
|
|
335
|
+
|
|
327
336
|
## Edit a plugin that is already installed
|
|
328
337
|
|
|
329
338
|
The host already swaps a rebuilt bundle without a page reload: it watches each plugin's entry artifact and reports a `rebuilt` frame on `/plugins/events`. `dev` puts the new file where the host is looking, then **proves** the frame arrived instead of asking you to check by eye.
|
package/lib/audit.mjs
CHANGED
|
@@ -111,6 +111,22 @@ function unreadableInstalled({ dir, name, profile, manifestPath, message }) {
|
|
|
111
111
|
};
|
|
112
112
|
}
|
|
113
113
|
|
|
114
|
+
/**
|
|
115
|
+
* A name in `dsh.profile.bundles` with no folder to mount. Unlike an ordinary
|
|
116
|
+
* dependency, this one is a declared plugin: the loader will look for it on
|
|
117
|
+
* startup, so a missing install has to appear in the audit instead of vanishing
|
|
118
|
+
* with the folder.
|
|
119
|
+
*/
|
|
120
|
+
function missingInstalled({ dir, name, profile }) {
|
|
121
|
+
return {
|
|
122
|
+
dir,
|
|
123
|
+
manifest: { name },
|
|
124
|
+
profile,
|
|
125
|
+
missing: true,
|
|
126
|
+
error: `${dir} is missing, so dsh.profile.bundles lists "${name}" but there is no node_modules/${name} folder to mount`,
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
114
130
|
/** Every package folder inside every profile, scoped names included. */
|
|
115
131
|
export function listInstalled({ home = DEFAULT_HOME } = {}) {
|
|
116
132
|
const root = resolvePath(home);
|
|
@@ -119,81 +135,99 @@ export function listInstalled({ home = DEFAULT_HOME } = {}) {
|
|
|
119
135
|
const found = [];
|
|
120
136
|
for (const profile of fs.readdirSync(profiles).sort()) {
|
|
121
137
|
const modules = path.join(profiles, profile, 'node_modules');
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
138
|
+
// Read the declarations before looking at node_modules: a declared bundle
|
|
139
|
+
// whose folder is gone is exactly the case this scan must not omit.
|
|
140
|
+
const declared = new Set(
|
|
141
|
+
readProfileBundles({ home, profile }).bundles.filter((name) => typeof name === 'string' && name.trim() !== ''),
|
|
142
|
+
);
|
|
143
|
+
const present = new Set();
|
|
144
|
+
if (fs.existsSync(modules) === true) {
|
|
145
|
+
for (const entry of fs.readdirSync(modules).sort()) {
|
|
146
|
+
if (entry.startsWith('.') === true) continue;
|
|
147
|
+
const candidates = entry.startsWith('@')
|
|
148
|
+
? fs
|
|
149
|
+
.readdirSync(path.join(modules, entry))
|
|
150
|
+
.sort()
|
|
151
|
+
.map((name) => ({ dir: path.join(modules, entry, name), name: `${entry}/${name}` }))
|
|
152
|
+
: [{ dir: path.join(modules, entry), name: entry }];
|
|
153
|
+
for (const { dir, name } of candidates) {
|
|
154
|
+
if (declared.has(name) === true) present.add(name);
|
|
155
|
+
// A broken package.json is only evidence of a plugin when the profile
|
|
156
|
+
// says it mounts that name. Without that record an ordinary dependency
|
|
157
|
+
// whose install was interrupted must stay out of the audit, or one bad
|
|
158
|
+
// transitive package would turn every profile red.
|
|
159
|
+
const listedInProfile = declared.has(name) === true;
|
|
160
|
+
const manifestPath = path.join(dir, 'package.json');
|
|
161
|
+
if (fs.existsSync(manifestPath) === false) {
|
|
162
|
+
if (listedInProfile === true) {
|
|
163
|
+
found.push(
|
|
164
|
+
unreadableInstalled({
|
|
165
|
+
dir,
|
|
166
|
+
name,
|
|
167
|
+
profile,
|
|
168
|
+
manifestPath,
|
|
169
|
+
message: `${manifestPath} is missing, so the installed copy has no manifest to read`,
|
|
170
|
+
}),
|
|
171
|
+
);
|
|
172
|
+
}
|
|
173
|
+
continue;
|
|
150
174
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
175
|
+
let manifest;
|
|
176
|
+
try {
|
|
177
|
+
// Strip the BOM the same way doctor does: a manifest saved by Notepad
|
|
178
|
+
// is still readable, and treating it as unreadable would be a false
|
|
179
|
+
// alarm in the other direction.
|
|
180
|
+
const text = String(fs.readFileSync(manifestPath, 'utf8')).replace(/^\uFEFF/u, '').trim();
|
|
181
|
+
manifest = JSON.parse(text);
|
|
182
|
+
} catch (error) {
|
|
183
|
+
// A package.json that is listed in the profile but does not parse is
|
|
184
|
+
// still an installed plugin, and "it does not parse" is exactly what
|
|
185
|
+
// the author needs to hear.
|
|
186
|
+
if (listedInProfile === true) {
|
|
187
|
+
found.push(
|
|
188
|
+
unreadableInstalled({
|
|
189
|
+
dir,
|
|
190
|
+
name,
|
|
191
|
+
profile,
|
|
192
|
+
manifestPath,
|
|
193
|
+
message: `${manifestPath} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`,
|
|
194
|
+
}),
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
continue;
|
|
174
198
|
}
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
199
|
+
if (manifest === null || typeof manifest !== 'object' || Array.isArray(manifest) === true) {
|
|
200
|
+
if (listedInProfile === true) {
|
|
201
|
+
found.push(
|
|
202
|
+
unreadableInstalled({
|
|
203
|
+
dir,
|
|
204
|
+
name,
|
|
205
|
+
profile,
|
|
206
|
+
manifestPath,
|
|
207
|
+
message: `${manifestPath} is readable JSON but not a package object, so its dsh field cannot be checked`,
|
|
208
|
+
}),
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
continue;
|
|
188
212
|
}
|
|
189
|
-
|
|
213
|
+
// Only packages that declare themselves as plugins. node_modules is full
|
|
214
|
+
// of ordinary dependencies, and auditing those is noise.
|
|
215
|
+
if (manifest.dsh === undefined) continue;
|
|
216
|
+
found.push({ dir, manifest, profile });
|
|
190
217
|
}
|
|
191
|
-
// Only packages that declare themselves as plugins. node_modules is full
|
|
192
|
-
// of ordinary dependencies, and auditing those is noise.
|
|
193
|
-
if (manifest.dsh === undefined) continue;
|
|
194
|
-
found.push({ dir, manifest, profile });
|
|
195
218
|
}
|
|
196
219
|
}
|
|
220
|
+
|
|
221
|
+
// A name can stay in `dsh.profile.bundles` after its folder is removed (an
|
|
222
|
+
// interrupted install, a deleted package). The loader still tries to mount
|
|
223
|
+
// it, so the audit reports the missing install instead of leaving only the
|
|
224
|
+
// healthy siblings visible.
|
|
225
|
+
for (const name of declared) {
|
|
226
|
+
if (present.has(name) === true) continue;
|
|
227
|
+
const dir = path.join(modules, name);
|
|
228
|
+
if (fs.existsSync(dir) === true) continue;
|
|
229
|
+
found.push(missingInstalled({ dir, name, profile }));
|
|
230
|
+
}
|
|
197
231
|
}
|
|
198
232
|
return found;
|
|
199
233
|
}
|
|
@@ -737,9 +771,13 @@ export async function audit({
|
|
|
737
771
|
}
|
|
738
772
|
|
|
739
773
|
const profileFiles = new Map();
|
|
740
|
-
const rows = installed.map(({ dir, manifest, profile, manifestPath, unreadable = false, error }) => {
|
|
774
|
+
const rows = installed.map(({ dir, manifest, profile, manifestPath, unreadable = false, missing = false, error }) => {
|
|
741
775
|
let failures;
|
|
742
|
-
if (
|
|
776
|
+
if (missing === true) {
|
|
777
|
+
// The folder is gone, so there is no manifest for doctor to read. The
|
|
778
|
+
// profile record is the evidence, and the row must name the absent path.
|
|
779
|
+
failures = [{ check: 'install', message: error }];
|
|
780
|
+
} else if (unreadable === true) {
|
|
743
781
|
// doctor would throw on the same file; keep the read error the install
|
|
744
782
|
// scan already recorded so the row names the unreadable package.json.
|
|
745
783
|
failures = [{ check: 'manifest', message: error }];
|
|
@@ -752,7 +790,12 @@ export async function audit({
|
|
|
752
790
|
}
|
|
753
791
|
const loaded = graph?.ok === true ? graph.ids.has(manifest.name) : null;
|
|
754
792
|
let explanation = null;
|
|
755
|
-
if (
|
|
793
|
+
if (missing === true) {
|
|
794
|
+
explanation = {
|
|
795
|
+
reason: `dsh.profile.bundles lists it, but ${dir} is missing, so there is no installed copy to mount`,
|
|
796
|
+
action: `reinstall ${manifest.name} (for example \`dsh plugin add ${manifest.name}\`), then restart the app`,
|
|
797
|
+
};
|
|
798
|
+
} else if (unreadable === true) {
|
|
756
799
|
explanation = {
|
|
757
800
|
reason: `${manifestPath} is unreadable, so the loader cannot tell what to mount`,
|
|
758
801
|
action: `reinstall ${manifest.name} so its package.json is written completely`,
|
|
@@ -778,6 +821,7 @@ export async function audit({
|
|
|
778
821
|
...split(failures),
|
|
779
822
|
loaded,
|
|
780
823
|
unreadable: unreadable === true,
|
|
824
|
+
missing: missing === true,
|
|
781
825
|
reason: explanation?.reason ?? null,
|
|
782
826
|
action: explanation?.action ?? null,
|
|
783
827
|
};
|
|
@@ -787,11 +831,21 @@ export async function audit({
|
|
|
787
831
|
const detailIndent = ' '.repeat(width + 24);
|
|
788
832
|
for (const row of rows) {
|
|
789
833
|
const state =
|
|
790
|
-
row.
|
|
791
|
-
|
|
834
|
+
row.missing === true
|
|
835
|
+
? 'missing'
|
|
836
|
+
: row.unreadable === true
|
|
837
|
+
? 'unreadable'
|
|
838
|
+
: row.loaded === null
|
|
839
|
+
? '?'
|
|
840
|
+
: row.loaded === true
|
|
841
|
+
? 'loaded'
|
|
842
|
+
: 'not loaded';
|
|
843
|
+
const reason = row.missing === true || row.loaded === false || row.unreadable === true ? ` — ${row.reason}` : '';
|
|
792
844
|
io.log(`${row.name.padEnd(width)} ${String(row.version).padEnd(8)} ${state.padEnd(10)} ${describe(row)}${reason}`);
|
|
793
845
|
for (const failure of row.failures) io.log(`${' '.repeat(width + 22)}${failure.check}: ${failure.message}`);
|
|
794
|
-
if (row.loaded === false || row.unreadable === true)
|
|
846
|
+
if (row.missing === true || row.loaded === false || row.unreadable === true) {
|
|
847
|
+
io.log(`${detailIndent}fix: ${row.action}`);
|
|
848
|
+
}
|
|
795
849
|
}
|
|
796
850
|
|
|
797
851
|
const failed = rows.filter((row) => row.hard.length > 0);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-plugin-toolkit",
|
|
3
|
-
"version": "0.20.
|
|
3
|
+
"version": "0.20.17",
|
|
4
4
|
"description": "Preflight, release and test DeepSeek Harness plugins: check a folder or any GitHub repository, wait for npm to actually serve the version, and keep the market index honest.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|