@shrkcrft/cli 0.1.0-alpha.2 → 0.1.0-alpha.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/dist/audit/knowledge-audit-llm.d.ts +19 -0
- package/dist/audit/knowledge-audit-llm.d.ts.map +1 -0
- package/dist/audit/knowledge-audit-llm.js +164 -0
- package/dist/audit/knowledge-audit.d.ts +61 -0
- package/dist/audit/knowledge-audit.d.ts.map +1 -0
- package/dist/audit/knowledge-audit.js +203 -0
- package/dist/audit/knowledge-fix-plan-llm.d.ts +11 -0
- package/dist/audit/knowledge-fix-plan-llm.d.ts.map +1 -0
- package/dist/audit/knowledge-fix-plan-llm.js +141 -0
- package/dist/audit/knowledge-fix-plan.d.ts +41 -0
- package/dist/audit/knowledge-fix-plan.d.ts.map +1 -0
- package/dist/audit/knowledge-fix-plan.js +125 -0
- package/dist/audit/pipeline-audit-llm.d.ts +11 -0
- package/dist/audit/pipeline-audit-llm.d.ts.map +1 -0
- package/dist/audit/pipeline-audit-llm.js +134 -0
- package/dist/audit/pipeline-audit.d.ts +69 -0
- package/dist/audit/pipeline-audit.d.ts.map +1 -0
- package/dist/audit/pipeline-audit.js +166 -0
- package/dist/audit/templates-audit-llm.d.ts +19 -0
- package/dist/audit/templates-audit-llm.d.ts.map +1 -0
- package/dist/audit/templates-audit-llm.js +207 -0
- package/dist/audit/templates-audit.d.ts +63 -0
- package/dist/audit/templates-audit.d.ts.map +1 -0
- package/dist/audit/templates-audit.js +171 -0
- package/dist/audit/templates-fix-plan-llm.d.ts +19 -0
- package/dist/audit/templates-fix-plan-llm.d.ts.map +1 -0
- package/dist/audit/templates-fix-plan-llm.js +162 -0
- package/dist/audit/templates-fix-plan.d.ts +37 -0
- package/dist/audit/templates-fix-plan.d.ts.map +1 -0
- package/dist/audit/templates-fix-plan.js +174 -0
- package/dist/command-registry.d.ts +28 -0
- package/dist/command-registry.d.ts.map +1 -1
- package/dist/command-registry.js +91 -1
- package/dist/commands/ai-status.command.d.ts +19 -0
- package/dist/commands/ai-status.command.d.ts.map +1 -0
- package/dist/commands/ai-status.command.js +94 -0
- package/dist/commands/api-diff.command.d.ts +11 -0
- package/dist/commands/api-diff.command.d.ts.map +1 -0
- package/dist/commands/api-diff.command.js +144 -0
- package/dist/commands/apply.command.d.ts.map +1 -1
- package/dist/commands/apply.command.js +10 -2
- package/dist/commands/arch.command.d.ts +9 -0
- package/dist/commands/arch.command.d.ts.map +1 -0
- package/dist/commands/arch.command.js +186 -0
- package/dist/commands/ask.command.d.ts.map +1 -1
- package/dist/commands/ask.command.js +10 -9
- package/dist/commands/cache-align.command.d.ts +12 -0
- package/dist/commands/cache-align.command.d.ts.map +1 -0
- package/dist/commands/cache-align.command.js +78 -0
- package/dist/commands/check.command.d.ts.map +1 -1
- package/dist/commands/check.command.js +19 -2
- package/dist/commands/code-intel.command.d.ts +18 -0
- package/dist/commands/code-intel.command.d.ts.map +1 -0
- package/dist/commands/code-intel.command.js +146 -0
- package/dist/commands/codemod.command.d.ts.map +1 -1
- package/dist/commands/codemod.command.js +27 -6
- package/dist/commands/command-catalog.d.ts +15 -3
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/command-catalog.js +387 -34
- package/dist/commands/commands.command.d.ts.map +1 -1
- package/dist/commands/commands.command.js +4 -4
- package/dist/commands/completion.command.d.ts +10 -0
- package/dist/commands/completion.command.d.ts.map +1 -0
- package/dist/commands/completion.command.js +121 -0
- package/dist/commands/compress.command.d.ts +8 -0
- package/dist/commands/compress.command.d.ts.map +1 -0
- package/dist/commands/compress.command.js +147 -0
- package/dist/commands/constructs.command.d.ts.map +1 -1
- package/dist/commands/constructs.command.js +89 -23
- package/dist/commands/context.command.d.ts.map +1 -1
- package/dist/commands/context.command.js +121 -1
- package/dist/commands/contract-gate.command.d.ts.map +1 -1
- package/dist/commands/contract-gate.command.js +5 -1
- package/dist/commands/delegate.command.d.ts +65 -0
- package/dist/commands/delegate.command.d.ts.map +1 -0
- package/dist/commands/delegate.command.js +657 -0
- package/dist/commands/deps-audit.command.d.ts +23 -0
- package/dist/commands/deps-audit.command.d.ts.map +1 -0
- package/dist/commands/deps-audit.command.js +270 -0
- package/dist/commands/dev.command.d.ts.map +1 -1
- package/dist/commands/dev.command.js +5 -1
- package/dist/commands/diff-check.command.d.ts +30 -0
- package/dist/commands/diff-check.command.d.ts.map +1 -0
- package/dist/commands/diff-check.command.js +210 -0
- package/dist/commands/doctor.command.d.ts.map +1 -1
- package/dist/commands/doctor.command.js +162 -10
- package/dist/commands/export.command.d.ts.map +1 -1
- package/dist/commands/export.command.js +76 -3
- package/dist/commands/framework.command.d.ts +12 -0
- package/dist/commands/framework.command.d.ts.map +1 -0
- package/dist/commands/framework.command.js +180 -0
- package/dist/commands/gate.command.d.ts +15 -0
- package/dist/commands/gate.command.d.ts.map +1 -0
- package/dist/commands/gate.command.js +300 -0
- package/dist/commands/gen.command.d.ts.map +1 -1
- package/dist/commands/gen.command.js +13 -1
- package/dist/commands/graph-code-subverbs.d.ts +33 -0
- package/dist/commands/graph-code-subverbs.d.ts.map +1 -0
- package/dist/commands/graph-code-subverbs.js +1366 -0
- package/dist/commands/graph.command.d.ts.map +1 -1
- package/dist/commands/graph.command.js +31 -2
- package/dist/commands/help.command.d.ts +4 -3
- package/dist/commands/help.command.d.ts.map +1 -1
- package/dist/commands/help.command.js +86 -18
- package/dist/commands/helper.command.js +1 -1
- package/dist/commands/impact.command.d.ts.map +1 -1
- package/dist/commands/impact.command.js +171 -1
- package/dist/commands/import.command.d.ts.map +1 -1
- package/dist/commands/import.command.js +121 -5
- package/dist/commands/ingest.command.d.ts.map +1 -1
- package/dist/commands/ingest.command.js +5 -1
- package/dist/commands/init.command.d.ts.map +1 -1
- package/dist/commands/init.command.js +174 -7
- package/dist/commands/knowledge-author.command.d.ts.map +1 -1
- package/dist/commands/knowledge-author.command.js +9 -0
- package/dist/commands/knowledge-propose.command.d.ts.map +1 -1
- package/dist/commands/knowledge-propose.command.js +4 -2
- package/dist/commands/knowledge.command.d.ts.map +1 -1
- package/dist/commands/knowledge.command.js +26 -3
- package/dist/commands/migrate.command.d.ts +13 -0
- package/dist/commands/migrate.command.d.ts.map +1 -0
- package/dist/commands/migrate.command.js +152 -0
- package/dist/commands/move-plan.command.d.ts +23 -0
- package/dist/commands/move-plan.command.d.ts.map +1 -0
- package/dist/commands/move-plan.command.js +360 -0
- package/dist/commands/packs-new.d.ts +1 -1
- package/dist/commands/packs-new.d.ts.map +1 -1
- package/dist/commands/packs-new.js +5 -36
- package/dist/commands/packs.command.d.ts.map +1 -1
- package/dist/commands/packs.command.js +2 -10
- package/dist/commands/plan-context.command.d.ts +11 -0
- package/dist/commands/plan-context.command.d.ts.map +1 -0
- package/dist/commands/plan-context.command.js +85 -0
- package/dist/commands/preflight.command.d.ts.map +1 -1
- package/dist/commands/preflight.command.js +15 -0
- package/dist/commands/profiles.command.js +4 -4
- package/dist/commands/recommend.command.d.ts +6 -0
- package/dist/commands/recommend.command.d.ts.map +1 -1
- package/dist/commands/recommend.command.js +119 -5
- package/dist/commands/release.command.js +13 -13
- package/dist/commands/rule-graph-subverbs.d.ts +3 -0
- package/dist/commands/rule-graph-subverbs.d.ts.map +1 -0
- package/dist/commands/rule-graph-subverbs.js +132 -0
- package/dist/commands/rules.command.d.ts.map +1 -1
- package/dist/commands/rules.command.js +20 -3
- package/dist/commands/scaffold-validate.command.d.ts +22 -0
- package/dist/commands/scaffold-validate.command.d.ts.map +1 -0
- package/dist/commands/scaffold-validate.command.js +215 -0
- package/dist/commands/search-structural.command.d.ts +18 -0
- package/dist/commands/search-structural.command.d.ts.map +1 -0
- package/dist/commands/search-structural.command.js +376 -0
- package/dist/commands/search.command.js +1 -1
- package/dist/commands/smart-context.command.d.ts +67 -0
- package/dist/commands/smart-context.command.d.ts.map +1 -0
- package/dist/commands/smart-context.command.js +4728 -0
- package/dist/commands/spike.command.d.ts +22 -0
- package/dist/commands/spike.command.d.ts.map +1 -0
- package/dist/commands/spike.command.js +235 -0
- package/dist/commands/surface.command.d.ts +1 -0
- package/dist/commands/surface.command.d.ts.map +1 -1
- package/dist/commands/surface.command.js +10 -3
- package/dist/commands/task-context.command.d.ts.map +1 -1
- package/dist/commands/task-context.command.js +5 -17
- package/dist/commands/task.command.d.ts.map +1 -1
- package/dist/commands/task.command.js +8 -2
- package/dist/commands/template-quality.command.d.ts.map +1 -1
- package/dist/commands/template-quality.command.js +39 -3
- package/dist/commands/templates.command.d.ts.map +1 -1
- package/dist/commands/templates.command.js +37 -2
- package/dist/commands/tests.command.d.ts.map +1 -1
- package/dist/commands/tests.command.js +13 -2
- package/dist/commands/watch.command.d.ts +26 -0
- package/dist/commands/watch.command.d.ts.map +1 -0
- package/dist/commands/watch.command.js +456 -0
- package/dist/dashboard/code-intelligence-data.d.ts +33 -0
- package/dist/dashboard/code-intelligence-data.d.ts.map +1 -0
- package/dist/dashboard/code-intelligence-data.js +329 -0
- package/dist/dashboard/dashboard-api-server.d.ts.map +1 -1
- package/dist/dashboard/dashboard-api-server.js +256 -2
- package/dist/dashboard/knowledge-ask.d.ts +4 -0
- package/dist/dashboard/knowledge-ask.d.ts.map +1 -0
- package/dist/dashboard/knowledge-ask.js +112 -0
- package/dist/env/load-dotenv.d.ts +15 -0
- package/dist/env/load-dotenv.d.ts.map +1 -0
- package/dist/env/load-dotenv.js +70 -0
- package/dist/export/claude-commands-export.d.ts +60 -0
- package/dist/export/claude-commands-export.d.ts.map +1 -0
- package/dist/export/claude-commands-export.js +276 -0
- package/dist/export/export-formats.d.ts +1 -1
- package/dist/export/export-formats.d.ts.map +1 -1
- package/dist/export/export-formats.js +139 -12
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/init/init-templates.d.ts.map +1 -1
- package/dist/init/init-templates.js +133 -113
- package/dist/init/paths-advisory.d.ts +20 -0
- package/dist/init/paths-advisory.d.ts.map +1 -0
- package/dist/init/paths-advisory.js +88 -0
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +331 -17
- package/dist/output/ccr-store-config.d.ts +18 -0
- package/dist/output/ccr-store-config.d.ts.map +1 -0
- package/dist/output/ccr-store-config.js +41 -0
- package/dist/output/format-output.d.ts.map +1 -1
- package/dist/output/format-output.js +6 -1
- package/dist/output/output-compression.d.ts +15 -0
- package/dist/output/output-compression.d.ts.map +1 -0
- package/dist/output/output-compression.js +60 -0
- package/dist/output/resolve-compress-type.d.ts +22 -0
- package/dist/output/resolve-compress-type.d.ts.map +1 -0
- package/dist/output/resolve-compress-type.js +21 -0
- package/dist/output/watch-loop.d.ts +9 -1
- package/dist/output/watch-loop.d.ts.map +1 -1
- package/dist/output/watch-loop.js +13 -3
- package/dist/schemas/json-schemas.d.ts +384 -36
- package/dist/schemas/json-schemas.d.ts.map +1 -1
- package/dist/schemas/json-schemas.js +247 -36
- package/dist/surface/profiles.d.ts.map +1 -1
- package/dist/surface/profiles.js +54 -9
- package/dist/surface/surface-config-writer.d.ts.map +1 -1
- package/dist/surface/surface-config-writer.js +23 -11
- package/dist/validation/run-validation-loop.d.ts.map +1 -1
- package/dist/validation/run-validation-loop.js +5 -1
- package/package.json +35 -21
- package/dist/commands/plugin.command.d.ts +0 -11
- package/dist/commands/plugin.command.d.ts.map +0 -1
- package/dist/commands/plugin.command.js +0 -394
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import { compressContent } from '@shrkcrft/compress';
|
|
3
|
+
import { openCcrStore } from "./ccr-store-config.js";
|
|
4
|
+
import { resolveCompressType } from "./resolve-compress-type.js";
|
|
5
|
+
// Command output can be large (a full knowledge dump, a wide graph). Allow up to
|
|
6
|
+
// 64 MiB of captured stdout before spawnSync gives up.
|
|
7
|
+
const MAX_BUFFER = 64 * 1024 * 1024;
|
|
8
|
+
/**
|
|
9
|
+
* Implements the global `--compress` / `--ccr` flag: run a `shrk` command in a
|
|
10
|
+
* child process, capture its stdout, and emit a deterministically-compressed
|
|
11
|
+
* version (with the original cached for `shrk expand`). The command's own
|
|
12
|
+
* stderr is forwarded verbatim and its exit code is preserved.
|
|
13
|
+
*
|
|
14
|
+
* A SUBPROCESS (not in-process `process.stdout` capture) on purpose: some
|
|
15
|
+
* commands call `process.exit`, which would discard a buffered in-process
|
|
16
|
+
* capture mid-write; re-running the command isolates that and still yields the
|
|
17
|
+
* full output + real exit status. `childArgv` has already had the compress
|
|
18
|
+
* flags stripped, so the child never recurses.
|
|
19
|
+
*/
|
|
20
|
+
export function runCommandWithCompression(childArgv, directive, cwd) {
|
|
21
|
+
const runtime = process.argv[0];
|
|
22
|
+
const entry = process.argv[1];
|
|
23
|
+
if (!runtime || !entry) {
|
|
24
|
+
process.stderr.write('--compress: cannot determine the shrk entry point to re-run; emitting uncompressed.\n');
|
|
25
|
+
return 1;
|
|
26
|
+
}
|
|
27
|
+
// Resolve an explicit --compress-type up front so a typo is reported loudly
|
|
28
|
+
// (not silently auto-detected), even if the command ends up printing nothing.
|
|
29
|
+
const resolvedType = resolveCompressType(directive.type);
|
|
30
|
+
if (resolvedType.warning)
|
|
31
|
+
process.stderr.write(`${resolvedType.warning}\n`);
|
|
32
|
+
const res = spawnSync(runtime, [entry, ...childArgv], {
|
|
33
|
+
encoding: 'utf8',
|
|
34
|
+
maxBuffer: MAX_BUFFER,
|
|
35
|
+
env: process.env,
|
|
36
|
+
});
|
|
37
|
+
if (res.error) {
|
|
38
|
+
process.stderr.write(`--compress: failed to run the command (${res.error.message}); emitting nothing.\n`);
|
|
39
|
+
return 1;
|
|
40
|
+
}
|
|
41
|
+
// Forward the command's own stderr (warnings, summaries, errors) untouched.
|
|
42
|
+
if (res.stderr)
|
|
43
|
+
process.stderr.write(res.stderr);
|
|
44
|
+
const captured = res.stdout ?? '';
|
|
45
|
+
const code = res.status ?? (res.signal ? 1 : 0);
|
|
46
|
+
// Nothing on stdout (or the command failed) → don't fabricate output.
|
|
47
|
+
if (captured.length === 0)
|
|
48
|
+
return code;
|
|
49
|
+
const opts = { store: openCcrStore(cwd) };
|
|
50
|
+
if (directive.query)
|
|
51
|
+
opts.query = directive.query;
|
|
52
|
+
if (resolvedType.type)
|
|
53
|
+
opts.contentType = resolvedType.type;
|
|
54
|
+
const result = compressContent(captured, opts);
|
|
55
|
+
process.stdout.write(result.compressed.endsWith('\n') ? result.compressed : `${result.compressed}\n`);
|
|
56
|
+
const pct = Math.round(result.savings.ratio * 100);
|
|
57
|
+
const cached = result.ccrKey ? ` · original cached (shrk expand ${result.ccrKey})` : '';
|
|
58
|
+
process.stderr.write(`[--compress] ${result.strategy}: ~${result.savings.before} → ~${result.savings.after} tokens (−${pct}%, est.)${cached}\n`);
|
|
59
|
+
return code;
|
|
60
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { EContentType } from '@shrkcrft/compress';
|
|
2
|
+
/** Outcome of resolving a raw `--compress-type` string. */
|
|
3
|
+
export interface IResolvedCompressType {
|
|
4
|
+
/** The forced content type — set only when the raw value named a valid one. */
|
|
5
|
+
type?: EContentType;
|
|
6
|
+
/**
|
|
7
|
+
* A user-facing warning, set when the raw value was non-empty but
|
|
8
|
+
* unrecognized. The caller surfaces it (on stderr) so an explicit-but-typo'd
|
|
9
|
+
* `--compress-type` is reported rather than silently dropped.
|
|
10
|
+
*/
|
|
11
|
+
warning?: string;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolve a raw `--compress-type` flag value into a forced {@link EContentType}.
|
|
15
|
+
*
|
|
16
|
+
* An unrecognized, non-empty value is NOT silently ignored (the old behavior):
|
|
17
|
+
* it yields a `warning` listing the valid types, so the caller can tell the
|
|
18
|
+
* user their explicit choice was dropped before falling back to auto-detection.
|
|
19
|
+
* A missing or empty value is a no-op (auto-detect, no warning).
|
|
20
|
+
*/
|
|
21
|
+
export declare function resolveCompressType(raw: string | undefined): IResolvedCompressType;
|
|
22
|
+
//# sourceMappingURL=resolve-compress-type.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolve-compress-type.d.ts","sourceRoot":"","sources":["../../src/output/resolve-compress-type.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAKlD,2DAA2D;AAC3D,MAAM,WAAW,qBAAqB;IACpC,+EAA+E;IAC/E,IAAI,CAAC,EAAE,YAAY,CAAC;IACpB;;;;OAIG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,SAAS,GAAG,qBAAqB,CAOlF"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { EContentType } from '@shrkcrft/compress';
|
|
2
|
+
/** The valid `--compress-type` values: the EContentType wire strings. */
|
|
3
|
+
const VALID_TYPES = new Set(Object.values(EContentType));
|
|
4
|
+
/**
|
|
5
|
+
* Resolve a raw `--compress-type` flag value into a forced {@link EContentType}.
|
|
6
|
+
*
|
|
7
|
+
* An unrecognized, non-empty value is NOT silently ignored (the old behavior):
|
|
8
|
+
* it yields a `warning` listing the valid types, so the caller can tell the
|
|
9
|
+
* user their explicit choice was dropped before falling back to auto-detection.
|
|
10
|
+
* A missing or empty value is a no-op (auto-detect, no warning).
|
|
11
|
+
*/
|
|
12
|
+
export function resolveCompressType(raw) {
|
|
13
|
+
if (raw === undefined || raw === '')
|
|
14
|
+
return {};
|
|
15
|
+
if (VALID_TYPES.has(raw))
|
|
16
|
+
return { type: raw };
|
|
17
|
+
const valid = [...VALID_TYPES].sort().join(', ');
|
|
18
|
+
return {
|
|
19
|
+
warning: `--compress: unknown --compress-type "${raw}"; auto-detecting instead. Valid types: ${valid}.`,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -27,11 +27,19 @@ export interface IWatchPlan {
|
|
|
27
27
|
}
|
|
28
28
|
export declare function buildWatchPlan(options: IWatchLoopOptions, steps: readonly string[]): IWatchPlan;
|
|
29
29
|
import type { ParsedArgs } from '../command-registry.js';
|
|
30
|
+
export interface IWatchModeOptions {
|
|
31
|
+
/**
|
|
32
|
+
* Paths to watch when the user does not pass `--paths`. Defaults to
|
|
33
|
+
* `['sharkcraft']` if omitted. Use this for commands that scan code
|
|
34
|
+
* outside `sharkcraft/` (e.g. `check boundaries` scans the whole repo).
|
|
35
|
+
*/
|
|
36
|
+
defaultPaths?: readonly string[];
|
|
37
|
+
}
|
|
30
38
|
/**
|
|
31
39
|
* Run a command's `run` function inside a watch loop when --watch is set.
|
|
32
40
|
*
|
|
33
41
|
* @returns null if --watch is not set (caller proceeds as before), otherwise
|
|
34
42
|
* the exit code of the watch loop.
|
|
35
43
|
*/
|
|
36
|
-
export declare function maybeRunInWatchMode(args: ParsedArgs, runner: (innerArgs: ParsedArgs) => Promise<number
|
|
44
|
+
export declare function maybeRunInWatchMode(args: ParsedArgs, runner: (innerArgs: ParsedArgs) => Promise<number>, options?: IWatchModeOptions): Promise<number | null>;
|
|
37
45
|
//# sourceMappingURL=watch-loop.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watch-loop.d.ts","sourceRoot":"","sources":["../../src/output/watch-loop.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACvC;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,CAAC,CA6DjB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,0BAA0B,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,UAAU,CAYZ;AAED,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,
|
|
1
|
+
{"version":3,"file":"watch-loop.d.ts","sourceRoot":"","sources":["../../src/output/watch-loop.ts"],"names":[],"mappings":"AAYA,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,uCAAuC;IACvC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,wCAAwC;IACxC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yEAAyE;IACzE,KAAK,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC3B;AAED,MAAM,WAAW,kBAAkB;IACjC,4BAA4B;IAC5B,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC;CACvC;AAED,wBAAsB,YAAY,CAChC,OAAO,EAAE,iBAAiB,EAC1B,QAAQ,EAAE,kBAAkB,GAC3B,OAAO,CAAC,MAAM,CAAC,CA6DjB;AAED;;;GAGG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,0BAA0B,CAAC;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1B;AAED,wBAAgB,cAAc,CAC5B,OAAO,EAAE,iBAAiB,EAC1B,KAAK,EAAE,SAAS,MAAM,EAAE,GACvB,UAAU,CAYZ;AAED,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,WAAW,iBAAiB;IAChC;;;;OAIG;IACH,YAAY,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAClC;AAED;;;;;GAKG;AACH,wBAAsB,mBAAmB,CACvC,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,CAAC,SAAS,EAAE,UAAU,KAAK,OAAO,CAAC,MAAM,CAAC,EAClD,OAAO,GAAE,iBAAsB,GAC9B,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAqCxB"}
|
|
@@ -81,31 +81,41 @@ export function buildWatchPlan(options, steps) {
|
|
|
81
81
|
steps,
|
|
82
82
|
};
|
|
83
83
|
}
|
|
84
|
-
import { flagBool, flagNumber, resolveCwd } from "../command-registry.js";
|
|
84
|
+
import { flagBool, flagNumber, flagString, resolveCwd } from "../command-registry.js";
|
|
85
85
|
/**
|
|
86
86
|
* Run a command's `run` function inside a watch loop when --watch is set.
|
|
87
87
|
*
|
|
88
88
|
* @returns null if --watch is not set (caller proceeds as before), otherwise
|
|
89
89
|
* the exit code of the watch loop.
|
|
90
90
|
*/
|
|
91
|
-
export async function maybeRunInWatchMode(args, runner) {
|
|
91
|
+
export async function maybeRunInWatchMode(args, runner, options = {}) {
|
|
92
92
|
if (!flagBool(args, 'watch'))
|
|
93
93
|
return null;
|
|
94
94
|
const cwd = resolveCwd(args);
|
|
95
95
|
const debounce = flagNumber(args, 'debounce') ?? 300;
|
|
96
96
|
const once = flagBool(args, 'once');
|
|
97
|
+
const pathsFlag = flagString(args, 'paths');
|
|
98
|
+
const userPaths = pathsFlag
|
|
99
|
+
? pathsFlag.split(',').map((s) => s.trim()).filter((s) => s.length > 0)
|
|
100
|
+
: [];
|
|
101
|
+
const paths = userPaths.length > 0
|
|
102
|
+
? userPaths
|
|
103
|
+
: options.defaultPaths && options.defaultPaths.length > 0
|
|
104
|
+
? options.defaultPaths
|
|
105
|
+
: ['sharkcraft'];
|
|
97
106
|
// Strip --watch so the inner snapshot doesn't recurse.
|
|
98
107
|
const innerFlags = new Map(args.flags);
|
|
99
108
|
innerFlags.delete('watch');
|
|
100
109
|
innerFlags.delete('once');
|
|
101
110
|
innerFlags.delete('debounce');
|
|
111
|
+
innerFlags.delete('paths');
|
|
102
112
|
const innerArgs = {
|
|
103
113
|
positional: args.positional,
|
|
104
114
|
flags: innerFlags,
|
|
105
115
|
multiFlags: args.multiFlags,
|
|
106
116
|
...(args.globalCwd ? { globalCwd: args.globalCwd } : {}),
|
|
107
117
|
};
|
|
108
|
-
return runWatchLoop({ cwd, debounce, once }, {
|
|
118
|
+
return runWatchLoop({ cwd, debounce, once, paths }, {
|
|
109
119
|
snapshot: async () => {
|
|
110
120
|
const ts = new Date().toLocaleTimeString();
|
|
111
121
|
process.stdout.write(`\n[watch] ${ts}\n`);
|