@shrkcrft/cli 0.1.0-alpha.16 → 0.1.0-alpha.18
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/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/apply.command.d.ts.map +1 -1
- package/dist/commands/apply.command.js +10 -2
- package/dist/commands/command-catalog.d.ts.map +1 -1
- package/dist/commands/command-catalog.js +14 -0
- package/dist/commands/compress.command.d.ts +0 -7
- package/dist/commands/compress.command.d.ts.map +1 -1
- package/dist/commands/compress.command.js +35 -13
- 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.js +5 -1
- package/dist/commands/dev.command.d.ts.map +1 -1
- package/dist/commands/dev.command.js +5 -1
- package/dist/commands/doctor.command.d.ts.map +1 -1
- package/dist/commands/doctor.command.js +24 -3
- package/dist/commands/graph-code-subverbs.d.ts +22 -0
- package/dist/commands/graph-code-subverbs.d.ts.map +1 -1
- package/dist/commands/graph-code-subverbs.js +450 -54
- package/dist/commands/graph.command.d.ts.map +1 -1
- package/dist/commands/graph.command.js +9 -3
- package/dist/commands/move-plan.command.js +1 -1
- package/dist/commands/smart-context.command.d.ts +26 -17
- package/dist/commands/smart-context.command.d.ts.map +1 -1
- package/dist/commands/smart-context.command.js +113 -16
- package/dist/commands/tests.command.d.ts.map +1 -1
- package/dist/commands/tests.command.js +13 -2
- package/dist/dashboard/code-intelligence-data.d.ts.map +1 -1
- package/dist/dashboard/code-intelligence-data.js +25 -3
- package/dist/main.d.ts.map +1 -1
- package/dist/main.js +21 -3
- 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/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/validation/run-validation-loop.d.ts.map +1 -1
- package/dist/validation/run-validation-loop.js +5 -1
- package/package.json +33 -33
|
@@ -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
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-validation-loop.d.ts","sourceRoot":"","sources":["../../src/validation/run-validation-loop.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,2EAA2E;IAC3E,gBAAgB,EAAE,OAAO,CAAC;IAC1B,6EAA6E;IAC7E,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,wBAAwB,EAAE,CAAC;IACxC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,
|
|
1
|
+
{"version":3,"file":"run-validation-loop.d.ts","sourceRoot":"","sources":["../../src/validation/run-validation-loop.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,wBAAwB;IACvC,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,OAAO,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,yBAAyB;IACxC,GAAG,EAAE,MAAM,CAAC;IACZ,qEAAqE;IACrE,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,mEAAmE;IACnE,eAAe,EAAE,SAAS,MAAM,EAAE,CAAC;IACnC,2EAA2E;IAC3E,gBAAgB,EAAE,OAAO,CAAC;IAC1B,6EAA6E;IAC7E,iBAAiB,EAAE,OAAO,CAAC;IAC3B,2DAA2D;IAC3D,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,+DAA+D;IAC/D,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,6EAA6E;IAC7E,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C;AAED,MAAM,WAAW,wBAAwB;IACvC,MAAM,EAAE,OAAO,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,wBAAwB,EAAE,CAAC;IACxC,cAAc,EAAE,MAAM,EAAE,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;;GAKG;AACH,wBAAsB,iBAAiB,CACrC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,wBAAwB,CAAC,CAyGnC"}
|
|
@@ -25,7 +25,11 @@ export async function runValidationLoop(options) {
|
|
|
25
25
|
const ver = cfg?.verificationCommands ?? [];
|
|
26
26
|
const wantIds = new Set(options.verificationIds);
|
|
27
27
|
for (const v of ver) {
|
|
28
|
-
|
|
28
|
+
// `--all-verifications` auto-runs commands, so it must respect the
|
|
29
|
+
// explicit `trusted: false` opt-out (a command the project marked
|
|
30
|
+
// untrusted must not be executed en masse). An explicit `--verification
|
|
31
|
+
// <id>` still runs it — naming it by id IS the opt-in.
|
|
32
|
+
const shouldRun = (options.allVerifications && v.trusted !== false) || wantIds.has(v.id);
|
|
29
33
|
if (!shouldRun)
|
|
30
34
|
continue;
|
|
31
35
|
commands.push({ id: v.id, command: v.command, trusted: v.trusted !== false });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@shrkcrft/cli",
|
|
3
|
-
"version": "0.1.0-alpha.
|
|
3
|
+
"version": "0.1.0-alpha.18",
|
|
4
4
|
"description": "SharkCraft CLI (`shrk`): structured project intelligence for AI coding agents.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "SharkCraft contributors",
|
|
@@ -47,38 +47,38 @@
|
|
|
47
47
|
"typecheck": "tsc --noEmit -p tsconfig.json"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"@shrkcrft/core": "^0.1.0-alpha.
|
|
51
|
-
"@shrkcrft/compress": "^0.1.0-alpha.
|
|
52
|
-
"@shrkcrft/config": "^0.1.0-alpha.
|
|
53
|
-
"@shrkcrft/workspace": "^0.1.0-alpha.
|
|
54
|
-
"@shrkcrft/knowledge": "^0.1.0-alpha.
|
|
55
|
-
"@shrkcrft/context": "^0.1.0-alpha.
|
|
56
|
-
"@shrkcrft/rules": "^0.1.0-alpha.
|
|
57
|
-
"@shrkcrft/paths": "^0.1.0-alpha.
|
|
58
|
-
"@shrkcrft/templates": "^0.1.0-alpha.
|
|
59
|
-
"@shrkcrft/plugin-api": "^0.1.0-alpha.
|
|
60
|
-
"@shrkcrft/dashboard": "^0.1.0-alpha.
|
|
61
|
-
"@shrkcrft/dashboard-api": "^0.1.0-alpha.
|
|
62
|
-
"@shrkcrft/pipelines": "^0.1.0-alpha.
|
|
63
|
-
"@shrkcrft/presets": "^0.1.0-alpha.
|
|
64
|
-
"@shrkcrft/boundaries": "^0.1.0-alpha.
|
|
65
|
-
"@shrkcrft/graph": "^0.1.0-alpha.
|
|
66
|
-
"@shrkcrft/rule-graph": "^0.1.0-alpha.
|
|
67
|
-
"@shrkcrft/structural-search": "^0.1.0-alpha.
|
|
68
|
-
"@shrkcrft/impact-engine": "^0.1.0-alpha.
|
|
69
|
-
"@shrkcrft/context-planner": "^0.1.0-alpha.
|
|
70
|
-
"@shrkcrft/architecture-guard": "^0.1.0-alpha.
|
|
71
|
-
"@shrkcrft/framework-scanners": "^0.1.0-alpha.
|
|
72
|
-
"@shrkcrft/api-surface-diff": "^0.1.0-alpha.
|
|
73
|
-
"@shrkcrft/quality-gates": "^0.1.0-alpha.
|
|
74
|
-
"@shrkcrft/migrate": "^0.1.0-alpha.
|
|
75
|
-
"@shrkcrft/generator": "^0.1.0-alpha.
|
|
76
|
-
"@shrkcrft/importer": "^0.1.0-alpha.
|
|
77
|
-
"@shrkcrft/inspector": "^0.1.0-alpha.
|
|
78
|
-
"@shrkcrft/ai": "^0.1.0-alpha.
|
|
79
|
-
"@shrkcrft/embeddings": "^0.1.0-alpha.
|
|
80
|
-
"@shrkcrft/shared": "^0.1.0-alpha.
|
|
81
|
-
"@shrkcrft/mcp-server": "^0.1.0-alpha.
|
|
50
|
+
"@shrkcrft/core": "^0.1.0-alpha.18",
|
|
51
|
+
"@shrkcrft/compress": "^0.1.0-alpha.18",
|
|
52
|
+
"@shrkcrft/config": "^0.1.0-alpha.18",
|
|
53
|
+
"@shrkcrft/workspace": "^0.1.0-alpha.18",
|
|
54
|
+
"@shrkcrft/knowledge": "^0.1.0-alpha.18",
|
|
55
|
+
"@shrkcrft/context": "^0.1.0-alpha.18",
|
|
56
|
+
"@shrkcrft/rules": "^0.1.0-alpha.18",
|
|
57
|
+
"@shrkcrft/paths": "^0.1.0-alpha.18",
|
|
58
|
+
"@shrkcrft/templates": "^0.1.0-alpha.18",
|
|
59
|
+
"@shrkcrft/plugin-api": "^0.1.0-alpha.18",
|
|
60
|
+
"@shrkcrft/dashboard": "^0.1.0-alpha.18",
|
|
61
|
+
"@shrkcrft/dashboard-api": "^0.1.0-alpha.18",
|
|
62
|
+
"@shrkcrft/pipelines": "^0.1.0-alpha.18",
|
|
63
|
+
"@shrkcrft/presets": "^0.1.0-alpha.18",
|
|
64
|
+
"@shrkcrft/boundaries": "^0.1.0-alpha.18",
|
|
65
|
+
"@shrkcrft/graph": "^0.1.0-alpha.18",
|
|
66
|
+
"@shrkcrft/rule-graph": "^0.1.0-alpha.18",
|
|
67
|
+
"@shrkcrft/structural-search": "^0.1.0-alpha.18",
|
|
68
|
+
"@shrkcrft/impact-engine": "^0.1.0-alpha.18",
|
|
69
|
+
"@shrkcrft/context-planner": "^0.1.0-alpha.18",
|
|
70
|
+
"@shrkcrft/architecture-guard": "^0.1.0-alpha.18",
|
|
71
|
+
"@shrkcrft/framework-scanners": "^0.1.0-alpha.18",
|
|
72
|
+
"@shrkcrft/api-surface-diff": "^0.1.0-alpha.18",
|
|
73
|
+
"@shrkcrft/quality-gates": "^0.1.0-alpha.18",
|
|
74
|
+
"@shrkcrft/migrate": "^0.1.0-alpha.18",
|
|
75
|
+
"@shrkcrft/generator": "^0.1.0-alpha.18",
|
|
76
|
+
"@shrkcrft/importer": "^0.1.0-alpha.18",
|
|
77
|
+
"@shrkcrft/inspector": "^0.1.0-alpha.18",
|
|
78
|
+
"@shrkcrft/ai": "^0.1.0-alpha.18",
|
|
79
|
+
"@shrkcrft/embeddings": "^0.1.0-alpha.18",
|
|
80
|
+
"@shrkcrft/shared": "^0.1.0-alpha.18",
|
|
81
|
+
"@shrkcrft/mcp-server": "^0.1.0-alpha.18",
|
|
82
82
|
"@huggingface/transformers": "^3.7.5"
|
|
83
83
|
},
|
|
84
84
|
"publishConfig": {
|