@ctxo/cli 0.13.1 → 0.15.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 +26 -1
- package/dist/chunk-2Q76LH2H.js +186 -0
- package/dist/chunk-72CEQEQD.js +53 -0
- package/dist/{chunk-WB7WZKX4.js → chunk-A4URKKPP.js} +916 -1938
- package/dist/chunk-BBSJB4CG.js +128 -0
- package/dist/{chunk-DT3ZH4AU.js → chunk-EC6INGPV.js} +6 -1
- package/dist/chunk-I7RPXT6L.js +1241 -0
- package/dist/chunk-IT426P3F.js +1036 -0
- package/dist/chunk-JDL6GGTO.js +87 -0
- package/dist/chunk-LAX6VVBU.js +98 -0
- package/dist/{cli-router-DDHH4WQH.js → cli-router-W56INOQ3.js} +980 -504
- package/dist/index.js +13 -2874
- package/dist/internal.d.ts +834 -0
- package/dist/internal.js +13 -0
- package/dist/{json-index-reader-OXTRTGE6.js → json-index-reader-DKEIP2QR.js} +6 -4
- package/dist/mcp-server-IYCCE74E.js +2336 -0
- package/dist/module-host-KTGDODES.js +13 -0
- package/dist/module-loader-B3LYF3W7.js +14 -0
- package/dist/plugin-discovery-XRXI3IJF.js +13 -0
- package/llms-full.txt +121 -2
- package/llms.txt +24 -1
- package/package.json +15 -3
- package/dist/atomic-write-BAFH464Q.js.map +0 -1
- package/dist/chunk-5DSKZJNN.js.map +0 -1
- package/dist/chunk-DT3ZH4AU.js.map +0 -1
- package/dist/chunk-PSKDDLSF.js.map +0 -1
- package/dist/chunk-RFEXMBTG.js.map +0 -1
- package/dist/chunk-WB7WZKX4.js.map +0 -1
- package/dist/cli-router-DDHH4WQH.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/json-index-reader-OXTRTGE6.js.map +0 -1
- package/dist/staleness-detector-4HJYBQ7Z.js.map +0 -1
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import {
|
|
3
|
+
compareCodepoint,
|
|
4
|
+
locateGitRoot
|
|
5
|
+
} from "./chunk-72CEQEQD.js";
|
|
6
|
+
import {
|
|
7
|
+
createLogger
|
|
8
|
+
} from "./chunk-5DSKZJNN.js";
|
|
9
|
+
|
|
10
|
+
// src/cli/module-commands.ts
|
|
11
|
+
import { join } from "path";
|
|
12
|
+
var log = createLogger("ctxo:modules");
|
|
13
|
+
var MODULE_COMMAND_PACKAGES = Object.freeze({
|
|
14
|
+
"verify-domain": "@ctxo/domain",
|
|
15
|
+
"contexts-touched": "@ctxo/domain",
|
|
16
|
+
domain: "@ctxo/domain",
|
|
17
|
+
"domain-guard-hook": "@ctxo/domain"
|
|
18
|
+
});
|
|
19
|
+
var FAST_ROUTE_COMMANDS = /* @__PURE__ */ new Set(["domain-guard-hook"]);
|
|
20
|
+
var CORE_COMMANDS = /* @__PURE__ */ new Set([
|
|
21
|
+
"index",
|
|
22
|
+
"sync",
|
|
23
|
+
"status",
|
|
24
|
+
"verify-index",
|
|
25
|
+
"init",
|
|
26
|
+
"watch",
|
|
27
|
+
"stats",
|
|
28
|
+
"doctor",
|
|
29
|
+
"visualize",
|
|
30
|
+
"version",
|
|
31
|
+
"install",
|
|
32
|
+
"update",
|
|
33
|
+
"blast-radius",
|
|
34
|
+
"contexts",
|
|
35
|
+
"gate",
|
|
36
|
+
"gate-hook"
|
|
37
|
+
]);
|
|
38
|
+
function isKnownModuleCommand(command) {
|
|
39
|
+
return Object.hasOwn(MODULE_COMMAND_PACKAGES, command);
|
|
40
|
+
}
|
|
41
|
+
function collectModuleCommands(modules, coreCommands) {
|
|
42
|
+
const commands = /* @__PURE__ */ new Map();
|
|
43
|
+
for (const module of modules) {
|
|
44
|
+
const register = module.registration.registerCommands;
|
|
45
|
+
if (typeof register !== "function") continue;
|
|
46
|
+
try {
|
|
47
|
+
register.call(module.registration, {
|
|
48
|
+
registerCommand: (command) => {
|
|
49
|
+
if (coreCommands.has(command.name)) {
|
|
50
|
+
log.warn(`${module.name} command "${command.name}" has the name of a core command and was ignored`);
|
|
51
|
+
} else if (commands.has(command.name)) {
|
|
52
|
+
log.warn(`${module.name} command "${command.name}" is already registered and was ignored`);
|
|
53
|
+
} else {
|
|
54
|
+
commands.set(command.name, command);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
} catch (err) {
|
|
59
|
+
log.warn(`${module.name} could not register its commands: ${err.message}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return commands;
|
|
63
|
+
}
|
|
64
|
+
async function readAllStdin() {
|
|
65
|
+
if (process.stdin.isTTY) return "";
|
|
66
|
+
const chunks = [];
|
|
67
|
+
for await (const chunk of process.stdin) {
|
|
68
|
+
chunks.push(typeof chunk === "string" ? Buffer.from(chunk, "utf-8") : chunk);
|
|
69
|
+
}
|
|
70
|
+
return Buffer.concat(chunks).toString("utf-8");
|
|
71
|
+
}
|
|
72
|
+
async function runModuleCommand(command, args, options) {
|
|
73
|
+
const found = collectModuleCommands(options.modules, CORE_COMMANDS).get(command);
|
|
74
|
+
if (found === void 0) return void 0;
|
|
75
|
+
if (args.some((arg) => arg === "--help" || arg === "-h")) {
|
|
76
|
+
console.error((found.usage ?? found.help).join("\n"));
|
|
77
|
+
return 0;
|
|
78
|
+
}
|
|
79
|
+
const ctx = {
|
|
80
|
+
projectRoot: options.projectRoot,
|
|
81
|
+
ctxoRoot: join(options.projectRoot, ".ctxo"),
|
|
82
|
+
readStdin: readAllStdin
|
|
83
|
+
};
|
|
84
|
+
return found.run(args, ctx);
|
|
85
|
+
}
|
|
86
|
+
function moduleHelpLines(modules) {
|
|
87
|
+
if (modules.length === 0) return [' Domain commands need @ctxo/domain: run "ctxo install domain"'];
|
|
88
|
+
const visible = [...collectModuleCommands(modules, CORE_COMMANDS).values()].filter((command) => command.hidden !== true).sort((a, b) => compareCodepoint(a.name, b.name));
|
|
89
|
+
const lines = visible.flatMap((command) => command.help.map((line) => ` ${line}`));
|
|
90
|
+
return lines.length === 0 ? [] : ["Domain commands (@ctxo/domain):", ...lines];
|
|
91
|
+
}
|
|
92
|
+
async function loadModulesFor(projectRoot, mode, options = {}) {
|
|
93
|
+
try {
|
|
94
|
+
const [{ DOMAIN_MODULE_PACKAGE, loadCtxoModules }, { resolvePackageCandidates }] = await Promise.all([
|
|
95
|
+
import("./module-loader-B3LYF3W7.js"),
|
|
96
|
+
import("./plugin-discovery-XRXI3IJF.js")
|
|
97
|
+
]);
|
|
98
|
+
if (resolvePackageCandidates(DOMAIN_MODULE_PACKAGE, projectRoot, options.cliAnchor).length === 0) return [];
|
|
99
|
+
const { createModuleHost } = await import("./module-host-KTGDODES.js");
|
|
100
|
+
const { modules } = await loadCtxoModules(createModuleHost({ projectRoot, mode }), { cliAnchor: options.cliAnchor });
|
|
101
|
+
return modules;
|
|
102
|
+
} catch (err) {
|
|
103
|
+
log.warn(`Modules could not be loaded: ${err.message}`);
|
|
104
|
+
return [];
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
async function runFastRoute(args, cwd, options = {}) {
|
|
108
|
+
const command = args[0] ?? "";
|
|
109
|
+
try {
|
|
110
|
+
const projectRoot = locateGitRoot(cwd) ?? cwd;
|
|
111
|
+
const modules = await loadModulesFor(projectRoot, "hook", { cliAnchor: options.cliAnchor });
|
|
112
|
+
const code = await runModuleCommand(command, args.slice(1), { projectRoot, modules });
|
|
113
|
+
return typeof code === "number" && Number.isInteger(code) ? code : 0;
|
|
114
|
+
} catch (err) {
|
|
115
|
+
console.error(`[ctxo] ${command} failed, allowing: ${err.message}`);
|
|
116
|
+
return 0;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
FAST_ROUTE_COMMANDS,
|
|
122
|
+
isKnownModuleCommand,
|
|
123
|
+
runModuleCommand,
|
|
124
|
+
moduleHelpLines,
|
|
125
|
+
loadModulesFor,
|
|
126
|
+
runFastRoute
|
|
127
|
+
};
|
|
128
|
+
//# sourceMappingURL=chunk-BBSJB4CG.js.map
|
|
@@ -130,6 +130,9 @@ var INDEX_ARTIFACT_FILES = [
|
|
|
130
130
|
"contexts-view.json"
|
|
131
131
|
];
|
|
132
132
|
var COMMUNITY_HISTORY_DIR = "communities.history";
|
|
133
|
+
function isMarkedArtifact(data) {
|
|
134
|
+
return data !== null && typeof data === "object" && !Array.isArray(data) && typeof data["ctxoArtifact"] === "string";
|
|
135
|
+
}
|
|
133
136
|
var JsonIndexReader = class {
|
|
134
137
|
indexDir;
|
|
135
138
|
constructor(ctxoRoot) {
|
|
@@ -161,6 +164,7 @@ var JsonIndexReader = class {
|
|
|
161
164
|
try {
|
|
162
165
|
const raw = readFileSync(absolutePath, "utf-8");
|
|
163
166
|
const data = JSON.parse(raw);
|
|
167
|
+
if (isMarkedArtifact(data)) return void 0;
|
|
164
168
|
const result = FileIndexSchema.safeParse(data);
|
|
165
169
|
if (result.success) {
|
|
166
170
|
return result.data;
|
|
@@ -259,6 +263,7 @@ export {
|
|
|
259
263
|
CoChangeMatrixSchema,
|
|
260
264
|
INDEX_ARTIFACT_FILES,
|
|
261
265
|
COMMUNITY_HISTORY_DIR,
|
|
266
|
+
isMarkedArtifact,
|
|
262
267
|
JsonIndexReader
|
|
263
268
|
};
|
|
264
|
-
//# sourceMappingURL=chunk-
|
|
269
|
+
//# sourceMappingURL=chunk-EC6INGPV.js.map
|