@singbox-iac/cli 0.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/LICENSE +21 -0
- package/README.md +265 -0
- package/dist/cli/command-helpers.d.ts +6 -0
- package/dist/cli/command-helpers.js +34 -0
- package/dist/cli/command-helpers.js.map +1 -0
- package/dist/cli/commands/apply.d.ts +2 -0
- package/dist/cli/commands/apply.js +32 -0
- package/dist/cli/commands/apply.js.map +1 -0
- package/dist/cli/commands/author.d.ts +2 -0
- package/dist/cli/commands/author.js +194 -0
- package/dist/cli/commands/author.js.map +1 -0
- package/dist/cli/commands/build.d.ts +2 -0
- package/dist/cli/commands/build.js +198 -0
- package/dist/cli/commands/build.js.map +1 -0
- package/dist/cli/commands/check.d.ts +2 -0
- package/dist/cli/commands/check.js +23 -0
- package/dist/cli/commands/check.js.map +1 -0
- package/dist/cli/commands/doctor.d.ts +2 -0
- package/dist/cli/commands/doctor.js +35 -0
- package/dist/cli/commands/doctor.js.map +1 -0
- package/dist/cli/commands/init.d.ts +2 -0
- package/dist/cli/commands/init.js +23 -0
- package/dist/cli/commands/init.js.map +1 -0
- package/dist/cli/commands/reload.d.ts +2 -0
- package/dist/cli/commands/reload.js +21 -0
- package/dist/cli/commands/reload.js.map +1 -0
- package/dist/cli/commands/run.d.ts +2 -0
- package/dist/cli/commands/run.js +25 -0
- package/dist/cli/commands/run.js.map +1 -0
- package/dist/cli/commands/schedule.d.ts +2 -0
- package/dist/cli/commands/schedule.js +77 -0
- package/dist/cli/commands/schedule.js.map +1 -0
- package/dist/cli/commands/templates.d.ts +2 -0
- package/dist/cli/commands/templates.js +34 -0
- package/dist/cli/commands/templates.js.map +1 -0
- package/dist/cli/commands/update.d.ts +2 -0
- package/dist/cli/commands/update.js +52 -0
- package/dist/cli/commands/update.js.map +1 -0
- package/dist/cli/commands/verify.d.ts +2 -0
- package/dist/cli/commands/verify.js +49 -0
- package/dist/cli/commands/verify.js.map +1 -0
- package/dist/cli/index.d.ts +5 -0
- package/dist/cli/index.js +55 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/config/load-config.d.ts +2 -0
- package/dist/config/load-config.js +29 -0
- package/dist/config/load-config.js.map +1 -0
- package/dist/config/schema.d.ts +548 -0
- package/dist/config/schema.js +92 -0
- package/dist/config/schema.js.map +1 -0
- package/dist/domain/config.d.ts +8 -0
- package/dist/domain/config.js +2 -0
- package/dist/domain/config.js.map +1 -0
- package/dist/domain/node.d.ts +11 -0
- package/dist/domain/node.js +2 -0
- package/dist/domain/node.js.map +1 -0
- package/dist/domain/outbound.d.ts +15 -0
- package/dist/domain/outbound.js +2 -0
- package/dist/domain/outbound.js.map +1 -0
- package/dist/domain/subscription.d.ts +6 -0
- package/dist/domain/subscription.js +2 -0
- package/dist/domain/subscription.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/dist/modules/authoring/index.d.ts +41 -0
- package/dist/modules/authoring/index.js +596 -0
- package/dist/modules/authoring/index.js.map +1 -0
- package/dist/modules/build/index.d.ts +13 -0
- package/dist/modules/build/index.js +39 -0
- package/dist/modules/build/index.js.map +1 -0
- package/dist/modules/compiler/index.d.ts +10 -0
- package/dist/modules/compiler/index.js +305 -0
- package/dist/modules/compiler/index.js.map +1 -0
- package/dist/modules/doctor/index.d.ts +17 -0
- package/dist/modules/doctor/index.js +89 -0
- package/dist/modules/doctor/index.js.map +1 -0
- package/dist/modules/fetcher/index.d.ts +4 -0
- package/dist/modules/fetcher/index.js +42 -0
- package/dist/modules/fetcher/index.js.map +1 -0
- package/dist/modules/init/index.d.ts +12 -0
- package/dist/modules/init/index.js +41 -0
- package/dist/modules/init/index.js.map +1 -0
- package/dist/modules/manager/index.d.ts +29 -0
- package/dist/modules/manager/index.js +133 -0
- package/dist/modules/manager/index.js.map +1 -0
- package/dist/modules/natural-language/index.d.ts +54 -0
- package/dist/modules/natural-language/index.js +458 -0
- package/dist/modules/natural-language/index.js.map +1 -0
- package/dist/modules/parser/index.d.ts +10 -0
- package/dist/modules/parser/index.js +113 -0
- package/dist/modules/parser/index.js.map +1 -0
- package/dist/modules/preview/index.d.ts +22 -0
- package/dist/modules/preview/index.js +141 -0
- package/dist/modules/preview/index.js.map +1 -0
- package/dist/modules/rule-templates/index.d.ts +15 -0
- package/dist/modules/rule-templates/index.js +200 -0
- package/dist/modules/rule-templates/index.js.map +1 -0
- package/dist/modules/schedule/index.d.ts +32 -0
- package/dist/modules/schedule/index.js +155 -0
- package/dist/modules/schedule/index.js.map +1 -0
- package/dist/modules/update/index.d.ts +22 -0
- package/dist/modules/update/index.js +38 -0
- package/dist/modules/update/index.js.map +1 -0
- package/dist/modules/user-rules/index.d.ts +18 -0
- package/dist/modules/user-rules/index.js +98 -0
- package/dist/modules/user-rules/index.js.map +1 -0
- package/dist/modules/verification/index.d.ts +49 -0
- package/dist/modules/verification/index.js +432 -0
- package/dist/modules/verification/index.js.map +1 -0
- package/dist/shared/errors.d.ts +3 -0
- package/dist/shared/errors.js +7 -0
- package/dist/shared/errors.js.map +1 -0
- package/dist/shared/logger.d.ts +2 -0
- package/dist/shared/logger.js +5 -0
- package/dist/shared/logger.js.map +1 -0
- package/dist/shared/result.d.ts +11 -0
- package/dist/shared/result.js +7 -0
- package/dist/shared/result.js.map +1 -0
- package/docs/antigravity-endpoints.md +77 -0
- package/docs/competitive-landscape.md +45 -0
- package/docs/development-workflow.md +80 -0
- package/docs/natural-language-authoring.md +376 -0
- package/docs/positioning.md +42 -0
- package/docs/releasing.md +72 -0
- package/docs/rule-templates.md +122 -0
- package/docs/rules-dsl.md +107 -0
- package/docs/runtime-on-macos.md +42 -0
- package/docs/sing-box-config-primer.md +39 -0
- package/docs/subscription-format.md +38 -0
- package/examples/builder.config.yaml +220 -0
- package/examples/custom.rules.yaml +18 -0
- package/package.json +51 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { buildConfigArtifact } from "../../modules/build/index.js";
|
|
2
|
+
import { assertVerificationReportPassed, verifyConfigRoutes, } from "../../modules/verification/index.js";
|
|
3
|
+
import { resolveBuilderConfig } from "../command-helpers.js";
|
|
4
|
+
export function registerVerifyCommand(program) {
|
|
5
|
+
program
|
|
6
|
+
.command("verify")
|
|
7
|
+
.description("Build and run closed-loop route verification with sing-box and Chrome.")
|
|
8
|
+
.option("-c, --config <path>", "path to builder config YAML")
|
|
9
|
+
.option("-i, --input <path>", "path to an existing config JSON to verify")
|
|
10
|
+
.option("--subscription-url <url>", "override subscription URL when rebuilding")
|
|
11
|
+
.option("--subscription-file <path>", "use a local subscription file instead of fetching")
|
|
12
|
+
.option("--sing-box-bin <path>", "path to sing-box binary")
|
|
13
|
+
.option("--chrome-bin <path>", "path to Chrome binary")
|
|
14
|
+
.action(async (options) => {
|
|
15
|
+
let configPath = options.input;
|
|
16
|
+
const builderConfig = await resolveBuilderConfig(options);
|
|
17
|
+
if (!configPath) {
|
|
18
|
+
if (!builderConfig) {
|
|
19
|
+
throw new Error("Verification requires --input or a builder config.");
|
|
20
|
+
}
|
|
21
|
+
const result = await buildConfigArtifact({
|
|
22
|
+
config: builderConfig,
|
|
23
|
+
...(options.subscriptionFile ? { subscriptionFile: options.subscriptionFile } : {}),
|
|
24
|
+
...(options.subscriptionUrl ? { subscriptionUrl: options.subscriptionUrl } : {}),
|
|
25
|
+
});
|
|
26
|
+
configPath = result.outputPath;
|
|
27
|
+
}
|
|
28
|
+
const report = await verifyConfigRoutes({
|
|
29
|
+
configPath,
|
|
30
|
+
...(options.singBoxBin ? { singBoxBinary: options.singBoxBin } : {}),
|
|
31
|
+
...(options.chromeBin ? { chromeBinary: options.chromeBin } : {}),
|
|
32
|
+
...(builderConfig ? { configuredScenarios: builderConfig.verification.scenarios } : {}),
|
|
33
|
+
});
|
|
34
|
+
const lines = [
|
|
35
|
+
`Verified config: ${report.configPath}`,
|
|
36
|
+
`Verification config: ${report.verifyConfigPath}`,
|
|
37
|
+
`sing-box log: ${report.logPath}`,
|
|
38
|
+
"",
|
|
39
|
+
"Static checks:",
|
|
40
|
+
...report.checks.map((check) => `- ${check.passed ? "PASS" : "FAIL"} ${check.name}: ${check.details}`),
|
|
41
|
+
"",
|
|
42
|
+
"Runtime scenarios:",
|
|
43
|
+
...report.scenarios.map((scenario) => `- ${scenario.passed ? "PASS" : "FAIL"} ${scenario.name} -> ${scenario.expectedOutboundTag} (${scenario.inboundTag})`),
|
|
44
|
+
];
|
|
45
|
+
process.stdout.write(`${lines.join("\n")}\n`);
|
|
46
|
+
assertVerificationReportPassed(report);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.js","sourceRoot":"","sources":["../../../src/cli/commands/verify.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AACnE,OAAO,EACL,8BAA8B,EAC9B,kBAAkB,GACnB,MAAM,qCAAqC,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,MAAM,UAAU,qBAAqB,CAAC,OAAgB;IACpD,OAAO;SACJ,OAAO,CAAC,QAAQ,CAAC;SACjB,WAAW,CAAC,wEAAwE,CAAC;SACrF,MAAM,CAAC,qBAAqB,EAAE,6BAA6B,CAAC;SAC5D,MAAM,CAAC,oBAAoB,EAAE,2CAA2C,CAAC;SACzE,MAAM,CAAC,0BAA0B,EAAE,2CAA2C,CAAC;SAC/E,MAAM,CAAC,4BAA4B,EAAE,mDAAmD,CAAC;SACzF,MAAM,CAAC,uBAAuB,EAAE,yBAAyB,CAAC;SAC1D,MAAM,CAAC,qBAAqB,EAAE,uBAAuB,CAAC;SACtD,MAAM,CAAC,KAAK,EAAE,OAA6B,EAAE,EAAE;QAC9C,IAAI,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC;QAC/B,MAAM,aAAa,GAAG,MAAM,oBAAoB,CAAC,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KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC,OAAO,EAAE,CACjF;YACD,EAAE;YACF,oBAAoB;YACpB,GAAG,MAAM,CAAC,SAAS,CAAC,GAAG,CACrB,CAAC,QAAQ,EAAE,EAAE,CACX,KAAK,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,QAAQ,CAAC,IAAI,OAAO,QAAQ,CAAC,mBAAmB,KAAK,QAAQ,CAAC,UAAU,GAAG,CACxH;SACF,CAAC;QAEF,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAE9C,8BAA8B,CAAC,MAAM,CAAC,CAAC;IACzC,CAAC,CAAC,CAAC;AACP,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from "commander";
|
|
3
|
+
export declare function createProgram(): Command;
|
|
4
|
+
export declare function run(argv: string[]): Promise<void>;
|
|
5
|
+
export declare function isDirectCliInvocation(cliModuleUrl: string, argvPath: string | undefined): boolean;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { realpathSync } from "node:fs";
|
|
3
|
+
import { fileURLToPath } from "node:url";
|
|
4
|
+
import { Command } from "commander";
|
|
5
|
+
import { registerApplyCommand } from "./commands/apply.js";
|
|
6
|
+
import { registerAuthorCommand } from "./commands/author.js";
|
|
7
|
+
import { registerBuildCommand } from "./commands/build.js";
|
|
8
|
+
import { registerCheckCommand } from "./commands/check.js";
|
|
9
|
+
import { registerDoctorCommand } from "./commands/doctor.js";
|
|
10
|
+
import { registerInitCommand } from "./commands/init.js";
|
|
11
|
+
import { registerReloadCommand } from "./commands/reload.js";
|
|
12
|
+
import { registerRunCommand } from "./commands/run.js";
|
|
13
|
+
import { registerScheduleCommand } from "./commands/schedule.js";
|
|
14
|
+
import { registerTemplatesCommand } from "./commands/templates.js";
|
|
15
|
+
import { registerUpdateCommand } from "./commands/update.js";
|
|
16
|
+
import { registerVerifyCommand } from "./commands/verify.js";
|
|
17
|
+
export function createProgram() {
|
|
18
|
+
const program = new Command();
|
|
19
|
+
program
|
|
20
|
+
.name("singbox-iac")
|
|
21
|
+
.description("Policy-first subscription compiler for sing-box on macOS.")
|
|
22
|
+
.version("0.1.0");
|
|
23
|
+
registerInitCommand(program);
|
|
24
|
+
registerAuthorCommand(program);
|
|
25
|
+
registerBuildCommand(program);
|
|
26
|
+
registerCheckCommand(program);
|
|
27
|
+
registerApplyCommand(program);
|
|
28
|
+
registerRunCommand(program);
|
|
29
|
+
registerVerifyCommand(program);
|
|
30
|
+
registerUpdateCommand(program);
|
|
31
|
+
registerDoctorCommand(program);
|
|
32
|
+
registerReloadCommand(program);
|
|
33
|
+
registerScheduleCommand(program);
|
|
34
|
+
registerTemplatesCommand(program);
|
|
35
|
+
return program;
|
|
36
|
+
}
|
|
37
|
+
export async function run(argv) {
|
|
38
|
+
await createProgram().parseAsync(argv);
|
|
39
|
+
}
|
|
40
|
+
export function isDirectCliInvocation(cliModuleUrl, argvPath) {
|
|
41
|
+
if (!argvPath) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const cliPath = fileURLToPath(cliModuleUrl);
|
|
45
|
+
try {
|
|
46
|
+
return realpathSync(cliPath) === realpathSync(argvPath);
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
return cliPath === argvPath;
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if (isDirectCliInvocation(import.meta.url, process.argv[1])) {
|
|
53
|
+
void run(process.argv);
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,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C9B,kBAAkB,CAAC,OAAO,CAAC,CAAC;IAC5B,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,qBAAqB,CAAC,OAAO,CAAC,CAAC;IAC/B,uBAAuB,CAAC,OAAO,CAAC,CAAC;IACjC,wBAAwB,CAAC,OAAO,CAAC,CAAC;IAElC,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,GAAG,CAAC,IAAc;IACtC,MAAM,aAAa,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;AACzC,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,YAAoB,EAAE,QAA4B;IACtF,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,OAAO,KAAK,CAAC;IACf,CAAC;IAED,MAAM,OAAO,GAAG,aAAa,CAAC,YAAY,CAAC,CAAC;IAE5C,IAAI,CAAC;QACH,OAAO,YAAY,CAAC,OAAO,CAAC,KAAK,YAAY,CAAC,QAAQ,CAAC,CAAC;IAC1D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,OAAO,KAAK,QAAQ,CAAC;IAC9B,CAAC;AACH,CAAC;AAED,IAAI,qBAAqB,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAC5D,KAAK,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;AACzB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { readFile } from "node:fs/promises";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import YAML from "yaml";
|
|
5
|
+
import { builderConfigSchema } from "./schema.js";
|
|
6
|
+
export async function loadConfig(filePath) {
|
|
7
|
+
const raw = await readFile(filePath, "utf8");
|
|
8
|
+
const parsed = YAML.parse(raw);
|
|
9
|
+
return builderConfigSchema.parse(expandBuilderPaths(parsed));
|
|
10
|
+
}
|
|
11
|
+
function expandBuilderPaths(input) {
|
|
12
|
+
if (typeof input === "string") {
|
|
13
|
+
return expandHome(input);
|
|
14
|
+
}
|
|
15
|
+
if (Array.isArray(input)) {
|
|
16
|
+
return input.map(expandBuilderPaths);
|
|
17
|
+
}
|
|
18
|
+
if (input && typeof input === "object") {
|
|
19
|
+
return Object.fromEntries(Object.entries(input).map(([key, value]) => [key, expandBuilderPaths(value)]));
|
|
20
|
+
}
|
|
21
|
+
return input;
|
|
22
|
+
}
|
|
23
|
+
function expandHome(value) {
|
|
24
|
+
if (!value.startsWith("~/")) {
|
|
25
|
+
return value;
|
|
26
|
+
}
|
|
27
|
+
return path.join(homedir(), value.slice(2));
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=load-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"load-config.js","sourceRoot":"","sources":["../../src/config/load-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,OAAO,EAAsB,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAEtE,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,QAAgB;IAC/C,MAAM,GAAG,GAAG,MAAM,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC/B,OAAO,mBAAmB,CAAC,KAAK,CAAC,kBAAkB,CAAC,MAAM,CAAC,CAAC,CAAC;AAC/D,CAAC;AAED,SAAS,kBAAkB,CAAC,KAAc;IACxC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAA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