@pugi/cli 0.1.0-beta.2 → 0.1.0-beta.20
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/THIRD_PARTY_NOTICES.md +40 -0
- package/assets/pugi-mascot.ansi +15 -40
- package/bin/run.js +33 -1
- package/dist/commands/jobs-watch.js +201 -0
- package/dist/commands/jobs.js +15 -0
- package/dist/core/agent-progress/cleanup.js +134 -0
- package/dist/core/agent-progress/schema.js +144 -0
- package/dist/core/agent-progress/writer.js +101 -0
- package/dist/core/compact/auto-trigger.js +96 -0
- package/dist/core/compact/buffer-rewriter.js +115 -0
- package/dist/core/compact/summarizer.js +196 -0
- package/dist/core/compact/token-counter.js +108 -0
- package/dist/core/consensus/diff-capture.js +73 -0
- package/dist/core/context/index.js +7 -0
- package/dist/core/context/markdown-traverse.js +255 -0
- package/dist/core/cost/rate-card.js +129 -0
- package/dist/core/cost/tracker.js +221 -0
- package/dist/core/denial-tracking/index.js +8 -0
- package/dist/core/denial-tracking/state.js +264 -0
- package/dist/core/diagnostics/probe-runner.js +93 -0
- package/dist/core/diagnostics/probes/api.js +46 -0
- package/dist/core/diagnostics/probes/auth.js +86 -0
- package/dist/core/diagnostics/probes/cli-version.js +127 -0
- package/dist/core/diagnostics/probes/config.js +72 -0
- package/dist/core/diagnostics/probes/denial-tracking.js +57 -0
- package/dist/core/diagnostics/probes/disk.js +81 -0
- package/dist/core/diagnostics/probes/git.js +65 -0
- package/dist/core/diagnostics/probes/mcp.js +75 -0
- package/dist/core/diagnostics/probes/node.js +59 -0
- package/dist/core/diagnostics/probes/pnpm.js +36 -0
- package/dist/core/diagnostics/probes/session.js +74 -0
- package/dist/core/diagnostics/probes/status-snapshot.js +442 -0
- package/dist/core/diagnostics/probes/workspace.js +63 -0
- package/dist/core/diagnostics/types.js +70 -0
- package/dist/core/edits/dispatch.js +218 -2
- package/dist/core/edits/journal.js +199 -0
- package/dist/core/edits/layer-d-ast.js +557 -14
- package/dist/core/edits/verify-hook.js +273 -0
- package/dist/core/edits/worktree.js +111 -18
- package/dist/core/engine/anvil-client.js +115 -5
- package/dist/core/engine/budgets.js +89 -0
- package/dist/core/engine/context-prefix.js +155 -0
- package/dist/core/engine/intent.js +260 -0
- package/dist/core/engine/native-pugi.js +744 -210
- package/dist/core/engine/prompts.js +61 -6
- package/dist/core/engine/strip-internal-fields.js +124 -0
- package/dist/core/engine/tool-bridge.js +818 -31
- package/dist/core/file-cache.js +113 -1
- package/dist/core/init/scaffold.js +195 -0
- package/dist/core/lsp/client.js +174 -29
- package/dist/core/mcp/client.js +75 -6
- package/dist/core/mcp/http-server.js +553 -0
- package/dist/core/mcp/permission.js +190 -0
- package/dist/core/mcp/registry.js +24 -2
- package/dist/core/mcp/server-tools.js +219 -0
- package/dist/core/mcp/server.js +397 -0
- package/dist/core/permissions/gate.js +187 -0
- package/dist/core/permissions/index.js +18 -0
- package/dist/core/permissions/mode.js +102 -0
- package/dist/core/permissions/state.js +160 -0
- package/dist/core/permissions/tool-class.js +93 -0
- package/dist/core/repl/codebase-survey.js +308 -0
- package/dist/core/repl/history.js +11 -1
- package/dist/core/repl/init-interview.js +457 -0
- package/dist/core/repl/model-pricing.js +135 -0
- package/dist/core/repl/onboarding-state.js +297 -0
- package/dist/core/repl/session.js +719 -29
- package/dist/core/repl/slash-commands.js +133 -9
- package/dist/core/retry-budget/budget.js +284 -0
- package/dist/core/retry-budget/index.js +5 -0
- package/dist/core/settings.js +71 -0
- package/dist/core/skills/defaults.js +457 -0
- package/dist/core/subagents/dispatcher-real.js +600 -0
- package/dist/core/subagents/dispatcher.js +113 -24
- package/dist/core/subagents/index.js +18 -5
- package/dist/core/subagents/isolation-matrix.js +213 -0
- package/dist/core/subagents/spawn.js +19 -4
- package/dist/core/transport/version-interceptor.js +166 -0
- package/dist/index.js +28 -0
- package/dist/runtime/bootstrap.js +190 -0
- package/dist/runtime/cli.js +1588 -266
- package/dist/runtime/commands/compact.js +296 -0
- package/dist/runtime/commands/cost.js +199 -0
- package/dist/runtime/commands/delegate.js +289 -0
- package/dist/runtime/commands/doctor.js +369 -0
- package/dist/runtime/commands/lsp.js +187 -5
- package/dist/runtime/commands/mcp.js +824 -0
- package/dist/runtime/commands/patch.js +17 -0
- package/dist/runtime/commands/permissions.js +87 -0
- package/dist/runtime/commands/report.js +299 -0
- package/dist/runtime/commands/review-consensus.js +17 -2
- package/dist/runtime/commands/roster.js +117 -0
- package/dist/runtime/commands/status.js +178 -0
- package/dist/runtime/commands/worktree.js +50 -6
- package/dist/runtime/headless.js +543 -0
- package/dist/runtime/load-hooks-or-exit.js +71 -0
- package/dist/runtime/plan-decompose.js +531 -0
- package/dist/runtime/version.js +65 -0
- package/dist/tools/agent-tool.js +206 -0
- package/dist/tools/apply-patch.js +281 -39
- package/dist/tools/ask-user-question.js +213 -0
- package/dist/tools/ask-user.js +115 -0
- package/dist/tools/file-tools.js +85 -14
- package/dist/tools/mcp-tool.js +260 -0
- package/dist/tools/multi-edit.js +361 -0
- package/dist/tools/registry.js +22 -2
- package/dist/tools/skill-tool.js +96 -0
- package/dist/tools/tasks.js +208 -0
- package/dist/tools/web-fetch.js +147 -2
- package/dist/tools/web-search.js +458 -0
- package/dist/tui/agent-progress-card.js +111 -0
- package/dist/tui/agent-tree.js +10 -0
- package/dist/tui/ask-modal.js +2 -2
- package/dist/tui/ask-user-question-prompt.js +192 -0
- package/dist/tui/compact-banner.js +54 -0
- package/dist/tui/conversation-pane.js +69 -8
- package/dist/tui/cost-table.js +111 -0
- package/dist/tui/doctor-table.js +31 -0
- package/dist/tui/input-box.js +1 -1
- package/dist/tui/markdown-render.js +4 -4
- package/dist/tui/repl-render.js +276 -37
- package/dist/tui/repl-splash.js +2 -2
- package/dist/tui/repl.js +25 -6
- package/dist/tui/splash.js +1 -1
- package/dist/tui/status-bar.js +94 -16
- package/dist/tui/status-table.js +7 -0
- package/dist/tui/tool-stream-pane.js +7 -0
- package/dist/tui/update-banner.js +20 -2
- package/docs/examples/codegraph.mcp.json +10 -0
- package/package.json +9 -6
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Project onboarding state for the Pugi REPL.
|
|
3
|
+
*
|
|
4
|
+
* Inspired by Claude Code's projectOnboardingState pattern (the leaked
|
|
5
|
+
* upstream file ships a 4-flag memoized check called on every prompt
|
|
6
|
+
* submit). Independent implementation: the storage location, the steps,
|
|
7
|
+
* the reset path, and the cap counter are all Pugi-shaped.
|
|
8
|
+
*
|
|
9
|
+
* # Why this exists
|
|
10
|
+
*
|
|
11
|
+
* The REPL's status bar can flash a `setup needed: run /init` hint when
|
|
12
|
+
* a workspace is still ungoverned (no PUGI.md, no skills installed). The
|
|
13
|
+
* hint must NEVER show on a workspace where the operator already ran the
|
|
14
|
+
* interview - otherwise the prompt becomes nag-noise. Three layered
|
|
15
|
+
* short-circuits guarantee that:
|
|
16
|
+
*
|
|
17
|
+
* 1. `hasCompletedOnboarding === true` in `~/.pugi/state.json` -> stop.
|
|
18
|
+
* The interview's final phase writes this flag once; subsequent
|
|
19
|
+
* REPL boots short-circuit at the global ledger and never even
|
|
20
|
+
* stat the workspace.
|
|
21
|
+
* 2. `onboardingSeenCount >= 4` -> stop. If the operator dismissed
|
|
22
|
+
* the hint four times without finishing the interview, assume they
|
|
23
|
+
* do not want it. The bar stays clean from boot 5 onward.
|
|
24
|
+
* 3. `PUGI_IS_DEMO=1` -> stop. The demo / snapshot recorder sets this
|
|
25
|
+
* so the screen capture stays free of onboarding chrome.
|
|
26
|
+
*
|
|
27
|
+
* If none short-circuit, the function checks the per-workspace steps
|
|
28
|
+
* (`PUGI.md` present, at least one skill installed, auth ok, workspace
|
|
29
|
+
* dir bound) and returns `true` only when at least one step is still
|
|
30
|
+
* incomplete.
|
|
31
|
+
*
|
|
32
|
+
* # Storage shape
|
|
33
|
+
*
|
|
34
|
+
* The global state file is JSON-on-disk at
|
|
35
|
+
* `~/.pugi/state.json`. It carries two scalars:
|
|
36
|
+
*
|
|
37
|
+
* {
|
|
38
|
+
* "hasCompletedOnboarding": boolean,
|
|
39
|
+
* "onboardingSeenCount": integer >= 0
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* The file is read at most once per process (memoized) so the hot path
|
|
43
|
+
* is in-memory. `incrementSeenCount()` re-reads the file before
|
|
44
|
+
* mutating to avoid clobbering a sibling Pugi process's increment
|
|
45
|
+
* (concurrent REPLs in two terminals). Atomic-ish: we write to
|
|
46
|
+
* `state.json.tmp` then rename. A race that overwrites another
|
|
47
|
+
* increment is benign - the worst case is a single missed +1 across
|
|
48
|
+
* two siblings.
|
|
49
|
+
*
|
|
50
|
+
* # Reset path
|
|
51
|
+
*
|
|
52
|
+
* `rm ~/.pugi/state.json` resets every flag. Tests rely on this:
|
|
53
|
+
* `resetOnboardingStateForTests(stateDir)` is the public helper that
|
|
54
|
+
* removes the file and clears the memoization cache.
|
|
55
|
+
*/
|
|
56
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, renameSync, rmSync, writeFileSync } from 'node:fs';
|
|
57
|
+
import { homedir } from 'node:os';
|
|
58
|
+
import { join } from 'node:path';
|
|
59
|
+
const DEFAULT_STATE = Object.freeze({
|
|
60
|
+
hasCompletedOnboarding: false,
|
|
61
|
+
onboardingSeenCount: 0,
|
|
62
|
+
});
|
|
63
|
+
/** Hard cap; once the operator has seen the hint this many times we stop. */
|
|
64
|
+
export const ONBOARDING_SEEN_CAP = 4;
|
|
65
|
+
/**
|
|
66
|
+
* Singleton memoization cache - cleared by `resetMemoizationForTests`.
|
|
67
|
+
* Keyed by stateDir so concurrent specs in the same process do not
|
|
68
|
+
* interfere with each other.
|
|
69
|
+
*/
|
|
70
|
+
const SHOULD_SHOW_CACHE = new Map();
|
|
71
|
+
const PERSISTED_STATE_CACHE = new Map();
|
|
72
|
+
/**
|
|
73
|
+
* Default fs implementation - the real `node:fs` module wrapped into
|
|
74
|
+
* the minimal surface this file uses.
|
|
75
|
+
*/
|
|
76
|
+
const REAL_FS = {
|
|
77
|
+
existsSync,
|
|
78
|
+
readFileSync: (path, encoding) => readFileSync(path, encoding),
|
|
79
|
+
writeFileSync: (path, data, options) => writeFileSync(path, data, options),
|
|
80
|
+
mkdirSync: (path, opts) => {
|
|
81
|
+
mkdirSync(path, opts);
|
|
82
|
+
},
|
|
83
|
+
renameSync,
|
|
84
|
+
rmSync: (path, opts) => rmSync(path, opts),
|
|
85
|
+
readdirSync: (path) => readdirSync(path),
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Compute the four Pugi-specific onboarding steps for the given
|
|
89
|
+
* workspace. Pure: the only side effect is the filesystem probe (which
|
|
90
|
+
* tests stub via `probes.fs`).
|
|
91
|
+
*/
|
|
92
|
+
export function getSteps(probes) {
|
|
93
|
+
const fs = probes.fs ?? REAL_FS;
|
|
94
|
+
const pugiDirPath = join(probes.cwd, '.pugi');
|
|
95
|
+
const hasWorkspaceDir = fs.existsSync(pugiDirPath);
|
|
96
|
+
const hasPugiMd = fs.existsSync(join(probes.cwd, 'PUGI.md')) ||
|
|
97
|
+
fs.existsSync(join(pugiDirPath, 'PUGI.md'));
|
|
98
|
+
const skillsDir = join(pugiDirPath, 'skills');
|
|
99
|
+
const hasSkill = fs.existsSync(skillsDir) && !isEmptyDir(skillsDir, fs);
|
|
100
|
+
return [
|
|
101
|
+
{
|
|
102
|
+
key: 'workspace',
|
|
103
|
+
text: 'Bind a workspace by running pugi init',
|
|
104
|
+
isComplete: hasWorkspaceDir,
|
|
105
|
+
isEnabled: true,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
key: 'pugimd',
|
|
109
|
+
text: 'Run /init to write PUGI.md with project context',
|
|
110
|
+
isComplete: hasPugiMd,
|
|
111
|
+
isEnabled: hasWorkspaceDir,
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
key: 'skills',
|
|
115
|
+
text: 'Install at least one skill under .pugi/skills/',
|
|
116
|
+
isComplete: hasSkill,
|
|
117
|
+
isEnabled: hasWorkspaceDir,
|
|
118
|
+
},
|
|
119
|
+
{
|
|
120
|
+
key: 'auth',
|
|
121
|
+
text: 'Run pugi login to authenticate',
|
|
122
|
+
isComplete: probes.authOk,
|
|
123
|
+
isEnabled: true,
|
|
124
|
+
},
|
|
125
|
+
];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Roll-up over the steps. True when every ENABLED step is complete -
|
|
129
|
+
* disabled steps (e.g. `pugimd` before `workspace` is set up) are
|
|
130
|
+
* excluded so the operator does not get stuck on a step they cannot
|
|
131
|
+
* action yet.
|
|
132
|
+
*/
|
|
133
|
+
export function isOnboardingComplete(probes) {
|
|
134
|
+
const steps = getSteps(probes);
|
|
135
|
+
return steps
|
|
136
|
+
.filter((s) => s.isEnabled)
|
|
137
|
+
.every((s) => s.isComplete);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The exported gate the REPL status bar consults. Memoized per
|
|
141
|
+
* stateDir; the hot path is one map lookup once the first call has run.
|
|
142
|
+
*/
|
|
143
|
+
export function shouldShowOnboarding(probes) {
|
|
144
|
+
const stateDir = probes.stateDir ?? defaultStateDir();
|
|
145
|
+
const cached = SHOULD_SHOW_CACHE.get(stateDir);
|
|
146
|
+
if (cached !== undefined)
|
|
147
|
+
return cached;
|
|
148
|
+
const persisted = loadPersistedState(stateDir, probes.fs ?? REAL_FS);
|
|
149
|
+
const isDemo = probes.isDemoOverride ?? (process.env.PUGI_IS_DEMO === '1');
|
|
150
|
+
if (persisted.hasCompletedOnboarding) {
|
|
151
|
+
SHOULD_SHOW_CACHE.set(stateDir, false);
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (persisted.onboardingSeenCount >= ONBOARDING_SEEN_CAP) {
|
|
155
|
+
SHOULD_SHOW_CACHE.set(stateDir, false);
|
|
156
|
+
return false;
|
|
157
|
+
}
|
|
158
|
+
if (isDemo) {
|
|
159
|
+
SHOULD_SHOW_CACHE.set(stateDir, false);
|
|
160
|
+
return false;
|
|
161
|
+
}
|
|
162
|
+
const verdict = !isOnboardingComplete(probes);
|
|
163
|
+
SHOULD_SHOW_CACHE.set(stateDir, verdict);
|
|
164
|
+
return verdict;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Idempotent setter: if the workspace is now fully onboarded, flip the
|
|
168
|
+
* persisted flag. Cheap to call on every prompt submit because the
|
|
169
|
+
* fast path short-circuits on the in-memory cache.
|
|
170
|
+
*
|
|
171
|
+
* The "maybe" prefix mirrors the upstream pattern: a no-op is the
|
|
172
|
+
* common case; the write only fires once when the operator's most
|
|
173
|
+
* recent action just completed the ladder.
|
|
174
|
+
*/
|
|
175
|
+
export function maybeMarkOnboardingComplete(probes) {
|
|
176
|
+
const stateDir = probes.stateDir ?? defaultStateDir();
|
|
177
|
+
const fs = probes.fs ?? REAL_FS;
|
|
178
|
+
const persisted = loadPersistedState(stateDir, fs);
|
|
179
|
+
if (persisted.hasCompletedOnboarding)
|
|
180
|
+
return;
|
|
181
|
+
if (!isOnboardingComplete(probes))
|
|
182
|
+
return;
|
|
183
|
+
persistState(stateDir, fs, { ...persisted, hasCompletedOnboarding: true });
|
|
184
|
+
// Invalidate the cache so the next `shouldShowOnboarding` call sees
|
|
185
|
+
// the new value without restarting the process.
|
|
186
|
+
SHOULD_SHOW_CACHE.delete(stateDir);
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Increment the seen counter. The REPL status bar calls this once per
|
|
190
|
+
* boot where it actually rendered the hint. After
|
|
191
|
+
* `ONBOARDING_SEEN_CAP` increments the cap guard in
|
|
192
|
+
* `shouldShowOnboarding` flips the gate off permanently for this user.
|
|
193
|
+
*/
|
|
194
|
+
export function incrementOnboardingSeenCount(probes) {
|
|
195
|
+
const stateDir = probes.stateDir ?? defaultStateDir();
|
|
196
|
+
const fs = probes.fs ?? REAL_FS;
|
|
197
|
+
const persisted = loadPersistedState(stateDir, fs);
|
|
198
|
+
const next = {
|
|
199
|
+
...persisted,
|
|
200
|
+
onboardingSeenCount: persisted.onboardingSeenCount + 1,
|
|
201
|
+
};
|
|
202
|
+
persistState(stateDir, fs, next);
|
|
203
|
+
SHOULD_SHOW_CACHE.delete(stateDir);
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Reset every persisted flag. Tests use this via the public helper; an
|
|
207
|
+
* operator can achieve the same effect by `rm ~/.pugi/state.json`.
|
|
208
|
+
*/
|
|
209
|
+
export function resetOnboardingStateForTests(probes) {
|
|
210
|
+
const stateDir = probes.stateDir ?? defaultStateDir();
|
|
211
|
+
const fs = probes.fs ?? REAL_FS;
|
|
212
|
+
const file = stateFilePath(stateDir);
|
|
213
|
+
if (fs.existsSync(file)) {
|
|
214
|
+
fs.rmSync(file, { force: true });
|
|
215
|
+
}
|
|
216
|
+
SHOULD_SHOW_CACHE.delete(stateDir);
|
|
217
|
+
PERSISTED_STATE_CACHE.delete(stateDir);
|
|
218
|
+
}
|
|
219
|
+
/**
|
|
220
|
+
* Clear the in-memory memoization without touching the disk. The
|
|
221
|
+
* spec uses this between assertions when it wants to force a re-read.
|
|
222
|
+
*/
|
|
223
|
+
export function resetMemoizationForTests(stateDir) {
|
|
224
|
+
if (stateDir) {
|
|
225
|
+
SHOULD_SHOW_CACHE.delete(stateDir);
|
|
226
|
+
PERSISTED_STATE_CACHE.delete(stateDir);
|
|
227
|
+
return;
|
|
228
|
+
}
|
|
229
|
+
SHOULD_SHOW_CACHE.clear();
|
|
230
|
+
PERSISTED_STATE_CACHE.clear();
|
|
231
|
+
}
|
|
232
|
+
/* ------------------------------------------------------------------ */
|
|
233
|
+
/* Internal helpers */
|
|
234
|
+
/* ------------------------------------------------------------------ */
|
|
235
|
+
function defaultStateDir() {
|
|
236
|
+
return join(homedir(), '.pugi');
|
|
237
|
+
}
|
|
238
|
+
function stateFilePath(stateDir) {
|
|
239
|
+
return join(stateDir, 'state.json');
|
|
240
|
+
}
|
|
241
|
+
function loadPersistedState(stateDir, fs) {
|
|
242
|
+
const cached = PERSISTED_STATE_CACHE.get(stateDir);
|
|
243
|
+
if (cached !== undefined)
|
|
244
|
+
return cached;
|
|
245
|
+
const file = stateFilePath(stateDir);
|
|
246
|
+
if (!fs.existsSync(file)) {
|
|
247
|
+
PERSISTED_STATE_CACHE.set(stateDir, DEFAULT_STATE);
|
|
248
|
+
return DEFAULT_STATE;
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const raw = fs.readFileSync(file, 'utf8');
|
|
252
|
+
const parsed = JSON.parse(raw);
|
|
253
|
+
const normalized = {
|
|
254
|
+
hasCompletedOnboarding: parsed.hasCompletedOnboarding === true,
|
|
255
|
+
onboardingSeenCount: typeof parsed.onboardingSeenCount === 'number' &&
|
|
256
|
+
Number.isFinite(parsed.onboardingSeenCount) &&
|
|
257
|
+
parsed.onboardingSeenCount >= 0
|
|
258
|
+
? Math.floor(parsed.onboardingSeenCount)
|
|
259
|
+
: 0,
|
|
260
|
+
};
|
|
261
|
+
PERSISTED_STATE_CACHE.set(stateDir, normalized);
|
|
262
|
+
return normalized;
|
|
263
|
+
}
|
|
264
|
+
catch {
|
|
265
|
+
// Corrupt file - treat as if it were absent. The next persist
|
|
266
|
+
// overwrites with a clean shape; we never crash the REPL boot on
|
|
267
|
+
// an unreadable state file.
|
|
268
|
+
PERSISTED_STATE_CACHE.set(stateDir, DEFAULT_STATE);
|
|
269
|
+
return DEFAULT_STATE;
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function persistState(stateDir, fs, next) {
|
|
273
|
+
if (!fs.existsSync(stateDir)) {
|
|
274
|
+
fs.mkdirSync(stateDir, { recursive: true });
|
|
275
|
+
}
|
|
276
|
+
const file = stateFilePath(stateDir);
|
|
277
|
+
const tmp = `${file}.tmp`;
|
|
278
|
+
fs.writeFileSync(tmp, `${JSON.stringify(next, null, 2)}\n`, { encoding: 'utf8', mode: 0o600 });
|
|
279
|
+
fs.renameSync(tmp, file);
|
|
280
|
+
PERSISTED_STATE_CACHE.set(stateDir, next);
|
|
281
|
+
}
|
|
282
|
+
function isEmptyDir(path, fs) {
|
|
283
|
+
// An empty `skills/` directory counts as "no skill installed yet" so
|
|
284
|
+
// the onboarding step stays incomplete. The injected fs shim may
|
|
285
|
+
// omit `readdirSync` - in that case we conservatively report
|
|
286
|
+
// non-empty (the dir existed, so the operator likely did something
|
|
287
|
+
// intentional) to avoid false-positive nag.
|
|
288
|
+
if (!fs.readdirSync)
|
|
289
|
+
return false;
|
|
290
|
+
try {
|
|
291
|
+
return fs.readdirSync(path).length === 0;
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
return true;
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=onboarding-state.js.map
|