prodex 2.0.0 → 2.1.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 +369 -146
- package/dist/app/dependency-source-provider.d.ts +2 -0
- package/dist/app/dependency-source-provider.js +66 -0
- package/dist/app/entry-resolver.d.ts +7 -0
- package/dist/app/entry-resolver.js +26 -0
- package/dist/app/execute-run.d.ts +2 -2
- package/dist/app/execute-run.js +138 -36
- package/dist/app/git-source-provider.d.ts +4 -0
- package/dist/app/git-source-provider.js +551 -0
- package/dist/app/grep-source-provider.d.ts +2 -0
- package/dist/app/grep-source-provider.js +226 -0
- package/dist/app/planner.d.ts +12 -0
- package/dist/app/planner.js +106 -0
- package/dist/app/planners/attachment-options.d.ts +2 -0
- package/dist/app/planners/attachment-options.js +39 -0
- package/dist/app/planners/git-plan.d.ts +13 -0
- package/dist/app/planners/git-plan.js +141 -0
- package/dist/app/planners/grep-plan.d.ts +13 -0
- package/dist/app/planners/grep-plan.js +115 -0
- package/dist/app/planners/list-utils.d.ts +1 -0
- package/dist/app/planners/list-utils.js +6 -0
- package/dist/app/planners/pack-plan.d.ts +13 -0
- package/dist/app/planners/pack-plan.js +65 -0
- package/dist/app/planners/scope-plan.d.ts +17 -0
- package/dist/app/planners/scope-plan.js +143 -0
- package/dist/app/planners/trace-plan.d.ts +13 -0
- package/dist/app/planners/trace-plan.js +77 -0
- package/dist/app/source-collector.d.ts +5 -0
- package/dist/app/source-collector.js +33 -0
- package/dist/app/target-resolver.d.ts +7 -0
- package/dist/app/target-resolver.js +110 -0
- package/dist/cli/cli-input.js +70 -19
- package/dist/cli/flag-specs.d.ts +7 -3
- package/dist/cli/flag-specs.js +58 -7
- package/dist/cli/help-specs.d.ts +205 -0
- package/dist/cli/help-specs.js +136 -0
- package/dist/cli/help.js +107 -28
- package/dist/cli/report-command.js +59 -26
- package/dist/commands/{run-command.d.ts → git-command.d.ts} +3 -3
- package/dist/commands/git-command.js +7 -0
- package/dist/commands/grep-command.d.ts +11 -0
- package/dist/commands/grep-command.js +7 -0
- package/dist/commands/pack-command.d.ts +11 -0
- package/dist/commands/pack-command.js +7 -0
- package/dist/commands/scope-command.d.ts +12 -0
- package/dist/commands/scope-command.js +7 -0
- package/dist/commands/shared-runner.d.ts +12 -0
- package/dist/commands/shared-runner.js +30 -0
- package/dist/commands/trace-command.d.ts +11 -0
- package/dist/commands/trace-command.js +7 -0
- package/dist/config/default-config.js +7 -11
- package/dist/config/load.d.ts +1 -0
- package/dist/config/load.js +269 -4
- package/dist/config/migration/detect.d.ts +2 -1
- package/dist/config/migration/detect.js +10 -2
- package/dist/config/migration/messages.js +12 -11
- package/dist/config/migration/transform.js +77 -32
- package/dist/filesystem/binary.d.ts +2 -0
- package/dist/filesystem/binary.js +30 -0
- package/dist/filesystem/entry-discovery.d.ts +14 -0
- package/dist/filesystem/entry-discovery.js +78 -0
- package/dist/filesystem/file-set.d.ts +7 -0
- package/dist/filesystem/file-set.js +57 -0
- package/dist/filesystem/glob-scan.d.ts +6 -2
- package/dist/filesystem/glob-scan.js +12 -7
- package/dist/filesystem/path-patterns.d.ts +20 -0
- package/dist/filesystem/path-patterns.js +70 -0
- package/dist/index.js +51 -29
- package/dist/output/markdown-sections.d.ts +5 -0
- package/dist/output/markdown-sections.js +103 -0
- package/dist/output/markdown-toc.d.ts +31 -0
- package/dist/output/markdown-toc.js +287 -0
- package/dist/output/markdown.d.ts +5 -8
- package/dist/output/markdown.js +80 -127
- package/dist/output/produce-output.d.ts +4 -1
- package/dist/output/produce-output.js +6 -7
- package/dist/output/render-helpers.d.ts +4 -0
- package/dist/output/render-helpers.js +14 -0
- package/dist/output/text.d.ts +2 -2
- package/dist/output/text.js +47 -8
- package/dist/resolvers/js/resolve-alias.js +10 -41
- package/dist/resolvers/php/bindings.js +6 -6
- package/dist/resolvers/php/extract-imports.d.ts +19 -7
- package/dist/resolvers/php/extract-imports.js +146 -26
- package/dist/resolvers/php/php-resolver.js +55 -24
- package/dist/resolvers/php/psr4.d.ts +1 -1
- package/dist/resolvers/php/psr4.js +7 -1
- package/dist/runtime/shell-command-runner.d.ts +5 -0
- package/dist/runtime/shell-command-runner.js +118 -0
- package/dist/tracing/collect-trace.d.ts +10 -0
- package/dist/tracing/collect-trace.js +23 -0
- package/dist/tracing/exclude.d.ts +0 -5
- package/dist/tracing/exclude.js +16 -12
- package/dist/tracing/follow-chain.js +2 -2
- package/dist/types/app.types.d.ts +38 -8
- package/dist/types/artifact.types.d.ts +50 -0
- package/dist/types/artifact.types.js +2 -0
- package/dist/types/cli.types.d.ts +52 -4
- package/dist/types/config.types.d.ts +37 -20
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/dist/types/output.types.d.ts +12 -3
- package/dist/types/planner.types.d.ts +76 -0
- package/dist/types/planner.types.js +2 -0
- package/dist/types/resolver.types.d.ts +1 -1
- package/dist/types/tracing.types.d.ts +0 -11
- package/package.json +2 -2
- package/schema/prodex.schema.json +59 -41
- package/dist/app/run-plans.d.ts +0 -11
- package/dist/app/run-plans.js +0 -61
- package/dist/commands/profiles-command.d.ts +0 -6
- package/dist/commands/profiles-command.js +0 -16
- package/dist/commands/run-command.js +0 -17
- package/dist/config/build-config.d.ts +0 -13
- package/dist/config/build-config.js +0 -127
- package/dist/tracing/include-files.d.ts +0 -2
- package/dist/tracing/include-files.js +0 -36
- package/dist/tracing/trace-run.d.ts +0 -2
- package/dist/tracing/trace-run.js +0 -21
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.executeAttachedCommand = executeAttachedCommand;
|
|
4
|
+
const child_process_1 = require("child_process");
|
|
5
|
+
/**
|
|
6
|
+
* Execute a single command sequentially using child_process.spawn.
|
|
7
|
+
*/
|
|
8
|
+
async function executeAttachedCommand(command, cwd, timeoutSeconds) {
|
|
9
|
+
const startTime = Date.now();
|
|
10
|
+
let stdout = "";
|
|
11
|
+
let stderr = "";
|
|
12
|
+
let combinedOutput = "";
|
|
13
|
+
let timedOut = false;
|
|
14
|
+
let status = "success";
|
|
15
|
+
let errorMessage;
|
|
16
|
+
return new Promise((resolve) => {
|
|
17
|
+
const child = (0, child_process_1.spawn)(command, {
|
|
18
|
+
shell: true,
|
|
19
|
+
cwd,
|
|
20
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
21
|
+
env: {
|
|
22
|
+
...process.env,
|
|
23
|
+
PAGER: "cat",
|
|
24
|
+
GIT_PAGER: "cat",
|
|
25
|
+
CI: process.env.CI ?? "1",
|
|
26
|
+
},
|
|
27
|
+
detached: process.platform !== "win32",
|
|
28
|
+
});
|
|
29
|
+
let timer;
|
|
30
|
+
if (timeoutSeconds > 0) {
|
|
31
|
+
timer = setTimeout(() => {
|
|
32
|
+
timedOut = true;
|
|
33
|
+
status = "timed-out";
|
|
34
|
+
if (child.pid) {
|
|
35
|
+
if (process.platform === "win32") {
|
|
36
|
+
(0, child_process_1.spawn)("taskkill", ["/pid", child.pid.toString(), "/t", "/f"], { stdio: "ignore" });
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
try {
|
|
40
|
+
process.kill(-child.pid, "SIGTERM");
|
|
41
|
+
}
|
|
42
|
+
catch { }
|
|
43
|
+
setTimeout(() => {
|
|
44
|
+
try {
|
|
45
|
+
process.kill(-child.pid, "SIGKILL");
|
|
46
|
+
}
|
|
47
|
+
catch { }
|
|
48
|
+
}, 2000);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
}, timeoutSeconds * 1000);
|
|
52
|
+
}
|
|
53
|
+
child.stdout?.on("data", (chunk) => {
|
|
54
|
+
const str = chunk.toString();
|
|
55
|
+
stdout += str;
|
|
56
|
+
combinedOutput += str;
|
|
57
|
+
});
|
|
58
|
+
child.stderr?.on("data", (chunk) => {
|
|
59
|
+
const str = chunk.toString();
|
|
60
|
+
stderr += str;
|
|
61
|
+
combinedOutput += str;
|
|
62
|
+
});
|
|
63
|
+
child.on("error", (err) => {
|
|
64
|
+
if (timer)
|
|
65
|
+
clearTimeout(timer);
|
|
66
|
+
status = "error";
|
|
67
|
+
errorMessage = err.message;
|
|
68
|
+
resolve({
|
|
69
|
+
command,
|
|
70
|
+
cwd,
|
|
71
|
+
status: "error",
|
|
72
|
+
exitCode: null,
|
|
73
|
+
signal: null,
|
|
74
|
+
durationMs: Date.now() - startTime,
|
|
75
|
+
timedOut: false,
|
|
76
|
+
stdout,
|
|
77
|
+
stderr,
|
|
78
|
+
combinedOutput,
|
|
79
|
+
errorMessage: err.message,
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
child.on("close", (code, signal) => {
|
|
83
|
+
if (timer)
|
|
84
|
+
clearTimeout(timer);
|
|
85
|
+
const durationMs = Date.now() - startTime;
|
|
86
|
+
if (status === "timed-out") {
|
|
87
|
+
resolve({
|
|
88
|
+
command,
|
|
89
|
+
cwd,
|
|
90
|
+
status: "timed-out",
|
|
91
|
+
exitCode: code,
|
|
92
|
+
signal,
|
|
93
|
+
durationMs,
|
|
94
|
+
timedOut: true,
|
|
95
|
+
stdout,
|
|
96
|
+
stderr,
|
|
97
|
+
combinedOutput,
|
|
98
|
+
});
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
if (code !== 0) {
|
|
102
|
+
status = "failed";
|
|
103
|
+
}
|
|
104
|
+
resolve({
|
|
105
|
+
command,
|
|
106
|
+
cwd,
|
|
107
|
+
status,
|
|
108
|
+
exitCode: code,
|
|
109
|
+
signal,
|
|
110
|
+
durationMs,
|
|
111
|
+
timedOut: false,
|
|
112
|
+
stdout,
|
|
113
|
+
stderr,
|
|
114
|
+
combinedOutput,
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ProdexConfig, TraceOptions, ChainResult } from "../types";
|
|
2
|
+
export interface CollectSourcesParams {
|
|
3
|
+
cfg: ProdexConfig;
|
|
4
|
+
opts: TraceOptions;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Pure source provider that resolves dependency chain and includes.
|
|
8
|
+
* Does not write output or have logging side-effects.
|
|
9
|
+
*/
|
|
10
|
+
export declare function collectTraceSources({ cfg, opts }: CollectSourcesParams): Promise<ChainResult>;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.collectTraceSources = collectTraceSources;
|
|
4
|
+
const follow_chain_1 = require("./follow-chain");
|
|
5
|
+
const file_set_1 = require("../filesystem/file-set");
|
|
6
|
+
/**
|
|
7
|
+
* Pure source provider that resolves dependency chain and includes.
|
|
8
|
+
* Does not write output or have logging side-effects.
|
|
9
|
+
*/
|
|
10
|
+
async function collectTraceSources({ cfg, opts }) {
|
|
11
|
+
const entries = opts.entries ?? [];
|
|
12
|
+
const result = entries.length ? await (0, follow_chain_1.followChain)(entries, cfg) : undefined;
|
|
13
|
+
const files = await (0, file_set_1.buildFinalFileSet)({
|
|
14
|
+
root: cfg.root,
|
|
15
|
+
sources: result?.files ?? [],
|
|
16
|
+
include: cfg.include ?? [],
|
|
17
|
+
exclude: cfg.exclude ?? [],
|
|
18
|
+
});
|
|
19
|
+
return {
|
|
20
|
+
files,
|
|
21
|
+
stats: result?.stats ?? { expected: new Set(), resolved: new Set() },
|
|
22
|
+
};
|
|
23
|
+
}
|
package/dist/tracing/exclude.js
CHANGED
|
@@ -6,22 +6,26 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.isExcluded = isExcluded;
|
|
7
7
|
const micromatch_1 = __importDefault(require("micromatch"));
|
|
8
8
|
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const read_file_1 = require("../filesystem/read-file");
|
|
10
9
|
const path_2 = require("../filesystem/path");
|
|
11
|
-
/**
|
|
12
|
-
* Centralized exclusion logic.
|
|
13
|
-
* Accepts namespaces, absolute paths, or relative paths
|
|
14
|
-
* and converts everything to a normalized, root-relative glob target.
|
|
15
|
-
*/
|
|
16
10
|
function isExcluded(p, patterns = [], root = process.cwd()) {
|
|
17
11
|
if (!patterns?.length)
|
|
18
12
|
return false;
|
|
19
13
|
if (!p)
|
|
20
14
|
return false;
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
const normAbsolute = (0, path_2.normalizePath)(path_1.default.resolve(root, p));
|
|
16
|
+
const normRelative = (0, path_2.normalizePath)(path_1.default.relative(root, normAbsolute));
|
|
17
|
+
for (const pattern of patterns) {
|
|
18
|
+
const normPattern = (0, path_2.normalizePath)(pattern);
|
|
19
|
+
if (path_1.default.isAbsolute(normPattern)) {
|
|
20
|
+
if (micromatch_1.default.isMatch(normAbsolute, normPattern)) {
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
if (micromatch_1.default.isMatch(normRelative, normPattern)) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
return false;
|
|
27
31
|
}
|
|
@@ -10,8 +10,8 @@ const exclude_1 = require("./exclude");
|
|
|
10
10
|
const trace_stats_1 = require("./trace-stats");
|
|
11
11
|
const resolver_registry_1 = require("./resolver-registry");
|
|
12
12
|
async function followChain(entryFiles, cfg) {
|
|
13
|
-
const limit = cfg.
|
|
14
|
-
const resolverDepth = cfg.
|
|
13
|
+
const limit = cfg.maxFiles;
|
|
14
|
+
const resolverDepth = cfg.depth;
|
|
15
15
|
logger_1.logger.debug("Following dependency chain...");
|
|
16
16
|
const visited = new Set();
|
|
17
17
|
const all = [];
|
|
@@ -2,17 +2,44 @@ import type { MigrationCommandResult } from "../config/migration";
|
|
|
2
2
|
import type { ProdexFlags } from "./cli.types";
|
|
3
3
|
import type { ProdexConfig } from "./config.types";
|
|
4
4
|
import type { ChainResult } from "./tracing.types";
|
|
5
|
+
import type { ArtifactSection, FileSnapshot } from "./artifact.types";
|
|
6
|
+
export type ProdexCommandKind = "pack" | "trace" | "scope" | "git" | "grep";
|
|
7
|
+
export type ProdexRunMode = "trace" | "include-only" | "mixed" | "git" | "grep";
|
|
8
|
+
export interface SourceCollectionResult {
|
|
9
|
+
files: string[];
|
|
10
|
+
entries: string[];
|
|
11
|
+
includes: string[];
|
|
12
|
+
mode: ProdexRunMode;
|
|
13
|
+
stats?: ChainResult["stats"];
|
|
14
|
+
warnings: string[];
|
|
15
|
+
errors: string[];
|
|
16
|
+
sections?: ArtifactSection[];
|
|
17
|
+
snapshots?: FileSnapshot[];
|
|
18
|
+
}
|
|
5
19
|
export type CliCommand = {
|
|
6
|
-
kind: "
|
|
20
|
+
kind: "pack";
|
|
7
21
|
rootArg?: string;
|
|
8
22
|
flags: Partial<ProdexFlags>;
|
|
9
23
|
} | {
|
|
10
|
-
kind: "
|
|
24
|
+
kind: "trace";
|
|
11
25
|
rootArg?: string;
|
|
12
|
-
|
|
26
|
+
flags: Partial<ProdexFlags>;
|
|
27
|
+
} | {
|
|
28
|
+
kind: "scope";
|
|
29
|
+
rootArg?: string;
|
|
30
|
+
flags: Partial<ProdexFlags>;
|
|
31
|
+
} | {
|
|
32
|
+
kind: "git";
|
|
33
|
+
rootArg?: string;
|
|
34
|
+
flags: Partial<ProdexFlags>;
|
|
13
35
|
} | {
|
|
14
|
-
kind: "
|
|
36
|
+
kind: "grep";
|
|
15
37
|
rootArg?: string;
|
|
38
|
+
flags: Partial<ProdexFlags>;
|
|
39
|
+
} | {
|
|
40
|
+
kind: "init";
|
|
41
|
+
rootArg?: string;
|
|
42
|
+
force?: boolean;
|
|
16
43
|
} | {
|
|
17
44
|
kind: "migrate";
|
|
18
45
|
rootArg?: string;
|
|
@@ -34,26 +61,29 @@ export interface RunPlan {
|
|
|
34
61
|
config: ProdexConfig;
|
|
35
62
|
flags: Partial<ProdexFlags>;
|
|
36
63
|
outputName?: string;
|
|
37
|
-
|
|
64
|
+
scopeKey?: string;
|
|
38
65
|
}
|
|
39
66
|
export interface RunResult {
|
|
40
67
|
ok: boolean;
|
|
41
68
|
root: string;
|
|
42
|
-
mode:
|
|
69
|
+
mode: ProdexRunMode;
|
|
43
70
|
outputPath?: string;
|
|
71
|
+
outputSizeBytes?: number;
|
|
72
|
+
outputName?: string;
|
|
44
73
|
entries: string[];
|
|
45
74
|
includes: string[];
|
|
46
75
|
files: string[];
|
|
47
76
|
stats?: ChainResult["stats"];
|
|
48
77
|
warnings: string[];
|
|
49
78
|
errors: string[];
|
|
50
|
-
|
|
79
|
+
scopeKey?: string;
|
|
80
|
+
plannedCommands?: string[];
|
|
51
81
|
}
|
|
52
82
|
export interface CommandResult {
|
|
53
83
|
ok: boolean;
|
|
54
84
|
exitCode: number;
|
|
55
85
|
message?: string;
|
|
56
|
-
|
|
86
|
+
scopes?: string[];
|
|
57
87
|
migration?: MigrationCommandResult;
|
|
58
88
|
warnings: string[];
|
|
59
89
|
errors: string[];
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { ProdexCommandKind, ProdexRunMode } from "./app.types";
|
|
2
|
+
export interface FileSnapshot {
|
|
3
|
+
path: string;
|
|
4
|
+
content: string;
|
|
5
|
+
readError?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface ArtifactSection {
|
|
8
|
+
id: string;
|
|
9
|
+
title: string;
|
|
10
|
+
kind: "text" | "code";
|
|
11
|
+
language?: string;
|
|
12
|
+
content: string;
|
|
13
|
+
}
|
|
14
|
+
export interface CommandOutputResult {
|
|
15
|
+
command: string;
|
|
16
|
+
cwd: string;
|
|
17
|
+
status: "success" | "failed" | "timed-out" | "error";
|
|
18
|
+
exitCode: number | null;
|
|
19
|
+
signal: string | null;
|
|
20
|
+
durationMs: number;
|
|
21
|
+
timedOut: boolean;
|
|
22
|
+
stdout: string;
|
|
23
|
+
stderr: string;
|
|
24
|
+
combinedOutput: string;
|
|
25
|
+
errorMessage?: string;
|
|
26
|
+
}
|
|
27
|
+
export interface ArtifactMetadata {
|
|
28
|
+
version: string;
|
|
29
|
+
timestamp: string;
|
|
30
|
+
commandKind: ProdexCommandKind;
|
|
31
|
+
mode: ProdexRunMode;
|
|
32
|
+
outputName?: string;
|
|
33
|
+
entries: string[];
|
|
34
|
+
includes: string[];
|
|
35
|
+
scopeKey?: string;
|
|
36
|
+
targets?: string[];
|
|
37
|
+
depth?: number;
|
|
38
|
+
}
|
|
39
|
+
export interface ArtifactPayload {
|
|
40
|
+
root: string;
|
|
41
|
+
sections?: ArtifactSection[];
|
|
42
|
+
files: FileSnapshot[];
|
|
43
|
+
commandOutputs?: CommandOutputResult[];
|
|
44
|
+
metadata: ArtifactMetadata;
|
|
45
|
+
}
|
|
46
|
+
export interface CommandAttachmentOptions {
|
|
47
|
+
commands: string[];
|
|
48
|
+
timeoutSeconds: number;
|
|
49
|
+
failOnError: boolean;
|
|
50
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
export interface ProdexFlags {
|
|
2
2
|
/** Entry globs or file paths. Repeatable and comma-aware. */
|
|
3
3
|
entry?: string[];
|
|
4
|
+
/** Target file/module to resolve and trace from. Repeatable and comma-aware. */
|
|
5
|
+
target?: string[];
|
|
4
6
|
/** Extra files or globs appended without dependency resolution. */
|
|
5
7
|
include?: string[];
|
|
6
8
|
/** Files or globs to skip during traversal. */
|
|
@@ -10,13 +12,59 @@ export interface ProdexFlags {
|
|
|
10
12
|
/** Output basename override for this run. */
|
|
11
13
|
name?: string | null;
|
|
12
14
|
/** Maximum dependency traversal depth. */
|
|
13
|
-
|
|
15
|
+
depth?: number | null;
|
|
14
16
|
/** Maximum number of files to trace. */
|
|
15
17
|
maxFiles?: number | null;
|
|
16
18
|
/** Enable debug logs. */
|
|
17
19
|
debug?: boolean;
|
|
18
|
-
/**
|
|
19
|
-
|
|
20
|
-
/**
|
|
20
|
+
/** Scopes to merge for pack command. */
|
|
21
|
+
scope?: string[];
|
|
22
|
+
/** Keys of scopes to run for scope command. */
|
|
23
|
+
key?: string[];
|
|
24
|
+
/** Run all scopes for scope command. */
|
|
25
|
+
all?: boolean;
|
|
26
|
+
/** List available scopes. */
|
|
27
|
+
list?: boolean;
|
|
28
|
+
/** Perform a dry-run execution. */
|
|
29
|
+
dryRun?: boolean;
|
|
30
|
+
/** Sequential attached shell commands to execute. */
|
|
31
|
+
cmd?: string[];
|
|
32
|
+
/** Per-command timeout in seconds. */
|
|
33
|
+
cmdTimeout?: number | null;
|
|
34
|
+
/** Enforce strict mode, exiting nonzero if any command fails. */
|
|
35
|
+
failOnCmdError?: boolean;
|
|
36
|
+
/** Git-specific: Include staged, unstaged, and untracked changes. */
|
|
37
|
+
changed?: boolean;
|
|
38
|
+
/** Git-specific: Include staged changes only. */
|
|
39
|
+
staged?: boolean;
|
|
40
|
+
/** Git-specific: Include unstaged changes only. */
|
|
41
|
+
unstaged?: boolean;
|
|
42
|
+
/** Git-specific: Include untracked files only. */
|
|
43
|
+
untracked?: boolean;
|
|
44
|
+
/** Git-specific: Include full git diff output in generic sections. */
|
|
45
|
+
includeDiff?: boolean;
|
|
46
|
+
/** Git-specific: Snapshot files changed by a single commit. */
|
|
47
|
+
commit?: string;
|
|
48
|
+
/** Git-specific: Snapshot files changed between two commits (base..head or base...head). */
|
|
49
|
+
range?: string;
|
|
50
|
+
/** Git-specific: Compare merge-base of base and HEAD against HEAD. */
|
|
51
|
+
against?: string;
|
|
52
|
+
/** Grep-specific: search query */
|
|
53
|
+
query?: string;
|
|
54
|
+
/** Grep-specific: comma-separated list of terms for OR search */
|
|
55
|
+
any?: string[];
|
|
56
|
+
/** Grep-specific: comma-separated list of terms for AND search */
|
|
57
|
+
grepAll?: string[];
|
|
58
|
+
/** Grep-specific: regex pattern for search */
|
|
59
|
+
regex?: string;
|
|
60
|
+
/** Grep-specific: negative terms list */
|
|
61
|
+
not?: string[];
|
|
62
|
+
/** Grep-specific: search only inside these paths/globs */
|
|
63
|
+
within?: string[];
|
|
64
|
+
/** Grep-specific: do not search inside these paths/globs */
|
|
65
|
+
skip?: string[];
|
|
66
|
+
/** Deprecated legacy flags */
|
|
67
|
+
profile?: string[];
|
|
21
68
|
allProfiles?: boolean;
|
|
69
|
+
maxDepth?: number | null;
|
|
22
70
|
}
|
|
@@ -1,34 +1,51 @@
|
|
|
1
|
-
export interface ProdexConfig
|
|
1
|
+
export interface ProdexConfig {
|
|
2
2
|
root: string;
|
|
3
3
|
name?: string;
|
|
4
|
+
dryRun?: boolean;
|
|
5
|
+
output: {
|
|
6
|
+
dir: string;
|
|
7
|
+
versioned: boolean;
|
|
8
|
+
format: "md" | "txt";
|
|
9
|
+
};
|
|
10
|
+
entry: string[];
|
|
11
|
+
include: string[];
|
|
12
|
+
exclude: string[];
|
|
13
|
+
aliases: Record<string, string>;
|
|
14
|
+
depth: number;
|
|
15
|
+
maxFiles: number;
|
|
16
|
+
scopes: Record<string, ProdexScope>;
|
|
17
|
+
}
|
|
18
|
+
export interface ProdexConfigFileOutput {
|
|
19
|
+
dir?: string;
|
|
20
|
+
versioned?: boolean;
|
|
21
|
+
format?: "md" | "txt";
|
|
4
22
|
}
|
|
5
|
-
export type ProdexConfigFile =
|
|
23
|
+
export type ProdexConfigFile = {
|
|
6
24
|
$schema: string;
|
|
7
25
|
version: number;
|
|
26
|
+
output?: ProdexConfigFileOutput;
|
|
27
|
+
exclude?: string[];
|
|
28
|
+
aliases?: Record<string, string>;
|
|
29
|
+
depth?: number;
|
|
30
|
+
maxFiles?: number;
|
|
31
|
+
scopes?: Record<string, ProdexScope>;
|
|
8
32
|
};
|
|
9
33
|
export type DeepPartial<T> = {
|
|
10
34
|
[K in keyof T]?: T[K] extends Array<infer Item> ? Item[] : T[K] extends object ? DeepPartial<T[K]> : T[K];
|
|
11
35
|
};
|
|
12
|
-
export
|
|
36
|
+
export interface ProdexGrepScopeConfig {
|
|
37
|
+
query?: string;
|
|
38
|
+
any?: string[];
|
|
39
|
+
all?: string[];
|
|
40
|
+
regex?: string;
|
|
41
|
+
not?: string[];
|
|
42
|
+
within?: string[];
|
|
43
|
+
skip?: string[];
|
|
44
|
+
}
|
|
45
|
+
export type ProdexScope = {
|
|
13
46
|
name?: string;
|
|
14
47
|
entry?: string[];
|
|
15
48
|
include?: string[];
|
|
16
49
|
exclude?: string[];
|
|
50
|
+
grep?: ProdexGrepScopeConfig;
|
|
17
51
|
};
|
|
18
|
-
interface ProdexBase {
|
|
19
|
-
output: {
|
|
20
|
-
dir: string;
|
|
21
|
-
versioned: boolean;
|
|
22
|
-
format: "md" | "txt";
|
|
23
|
-
};
|
|
24
|
-
entry: string[];
|
|
25
|
-
include: string[];
|
|
26
|
-
exclude: string[];
|
|
27
|
-
resolve: {
|
|
28
|
-
aliases: Record<string, string>;
|
|
29
|
-
maxDepth: number;
|
|
30
|
-
maxFiles: number;
|
|
31
|
-
};
|
|
32
|
-
profiles: Record<string, ProdexProfile>;
|
|
33
|
-
}
|
|
34
|
-
export {};
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -21,3 +21,5 @@ __exportStar(require("./output.types"), exports);
|
|
|
21
21
|
__exportStar(require("./resolver.types"), exports);
|
|
22
22
|
__exportStar(require("./utils.types"), exports);
|
|
23
23
|
__exportStar(require("./app.types"), exports);
|
|
24
|
+
__exportStar(require("./planner.types"), exports);
|
|
25
|
+
__exportStar(require("./artifact.types"), exports);
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ArtifactPayload } from "./artifact.types";
|
|
2
|
+
export type LayoutOrder = "files-first" | "sections-first";
|
|
3
|
+
export interface MdTraceEntry {
|
|
4
|
+
file: string;
|
|
5
|
+
anchor: number;
|
|
6
|
+
startLine: number;
|
|
7
|
+
endLine: number;
|
|
8
|
+
}
|
|
2
9
|
export interface OutputParams {
|
|
3
|
-
files: string[];
|
|
4
10
|
name: string;
|
|
5
|
-
|
|
11
|
+
payload: ArtifactPayload;
|
|
12
|
+
format: "md" | "txt";
|
|
13
|
+
dir: string;
|
|
14
|
+
versioned: boolean;
|
|
6
15
|
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import type { ProdexFlags } from "./cli.types";
|
|
2
|
+
import type { CommandAttachmentOptions } from "./artifact.types";
|
|
3
|
+
import type { ProdexCommandKind } from "./app.types";
|
|
4
|
+
export type CommandIntent = {
|
|
5
|
+
kind: "pack";
|
|
6
|
+
rootArg?: string;
|
|
7
|
+
flags: Partial<ProdexFlags>;
|
|
8
|
+
} | {
|
|
9
|
+
kind: "trace";
|
|
10
|
+
rootArg?: string;
|
|
11
|
+
flags: Partial<ProdexFlags>;
|
|
12
|
+
} | {
|
|
13
|
+
kind: "scope";
|
|
14
|
+
rootArg?: string;
|
|
15
|
+
flags: Partial<ProdexFlags>;
|
|
16
|
+
} | {
|
|
17
|
+
kind: "git";
|
|
18
|
+
rootArg?: string;
|
|
19
|
+
flags: Partial<ProdexFlags>;
|
|
20
|
+
} | {
|
|
21
|
+
kind: "grep";
|
|
22
|
+
rootArg?: string;
|
|
23
|
+
flags: Partial<ProdexFlags>;
|
|
24
|
+
};
|
|
25
|
+
export type GitPlanOptions = {
|
|
26
|
+
mode: "working-tree";
|
|
27
|
+
changed: boolean;
|
|
28
|
+
staged: boolean;
|
|
29
|
+
unstaged: boolean;
|
|
30
|
+
untracked: boolean;
|
|
31
|
+
includeDiff: boolean;
|
|
32
|
+
} | {
|
|
33
|
+
mode: "commit";
|
|
34
|
+
rev: string;
|
|
35
|
+
includeDiff: boolean;
|
|
36
|
+
} | {
|
|
37
|
+
mode: "range";
|
|
38
|
+
spec: string;
|
|
39
|
+
base: string;
|
|
40
|
+
head: string;
|
|
41
|
+
includeDiff: boolean;
|
|
42
|
+
} | {
|
|
43
|
+
mode: "against";
|
|
44
|
+
base: string;
|
|
45
|
+
mergeBase?: string;
|
|
46
|
+
includeDiff: boolean;
|
|
47
|
+
};
|
|
48
|
+
export interface GrepPlanOptions {
|
|
49
|
+
mode: "query" | "any" | "all" | "regex";
|
|
50
|
+
terms: string[];
|
|
51
|
+
negativeTerms: string[];
|
|
52
|
+
within: string[];
|
|
53
|
+
skip: string[];
|
|
54
|
+
}
|
|
55
|
+
export interface ExecutionPlan {
|
|
56
|
+
root: string;
|
|
57
|
+
command: ProdexCommandKind;
|
|
58
|
+
outputName?: string;
|
|
59
|
+
entry: string[];
|
|
60
|
+
target?: string[];
|
|
61
|
+
include: string[];
|
|
62
|
+
exclude: string[];
|
|
63
|
+
depth: number;
|
|
64
|
+
maxFiles: number;
|
|
65
|
+
aliases: Record<string, string>;
|
|
66
|
+
output: {
|
|
67
|
+
dir: string;
|
|
68
|
+
versioned: boolean;
|
|
69
|
+
format: "md" | "txt";
|
|
70
|
+
};
|
|
71
|
+
dryRun: boolean;
|
|
72
|
+
scopeKey?: string;
|
|
73
|
+
attachmentOptions?: CommandAttachmentOptions;
|
|
74
|
+
gitOptions?: GitPlanOptions;
|
|
75
|
+
grepOptions?: GrepPlanOptions;
|
|
76
|
+
}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ProdexConfig } from "./config.types";
|
|
2
1
|
export interface TraceStats {
|
|
3
2
|
expected: Set<string>;
|
|
4
3
|
resolved: Set<string>;
|
|
@@ -11,13 +10,3 @@ export interface TraceOptions {
|
|
|
11
10
|
entries: string[];
|
|
12
11
|
outputName?: string;
|
|
13
12
|
}
|
|
14
|
-
export interface TraceParams {
|
|
15
|
-
cfg: ProdexConfig;
|
|
16
|
-
opts: TraceOptions;
|
|
17
|
-
}
|
|
18
|
-
export interface TraceResult {
|
|
19
|
-
outputPath?: string;
|
|
20
|
-
entries: string[];
|
|
21
|
-
files: string[];
|
|
22
|
-
stats?: TraceStats;
|
|
23
|
-
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "prodex",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Focused code-context extractor for large projects.",
|
|
5
5
|
"type": "commonjs",
|
|
6
6
|
"packageManager": "npm@11.12.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"dev": "tsc --watch",
|
|
42
42
|
"gen:schema": "node schema/generate.js",
|
|
43
43
|
"check:architecture": "node scripts/check-architecture.js",
|
|
44
|
-
"test": "npm run check:architecture && npm run build && node --test test/cli-contract.test.js",
|
|
44
|
+
"test": "npm run check:architecture && npm run build && node --test test/cli-contract.test.js test/git-command.test.js test/cleanup.test.js test/grep-command.test.js test/resolvers-and-config.test.js",
|
|
45
45
|
"prepack": "npm run build",
|
|
46
46
|
"pack:check": "npm pack --dry-run"
|
|
47
47
|
},
|