@descryy/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/dist/bin/descry.d.ts +11 -0
- package/dist/bin/descry.d.ts.map +1 -0
- package/dist/bin/descry.js +171 -0
- package/dist/bin/descry.js.map +1 -0
- package/dist/commands/init.d.ts +48 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +223 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/viz.d.ts +16 -0
- package/dist/commands/viz.d.ts.map +1 -0
- package/dist/commands/viz.js +20 -0
- package/dist/commands/viz.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -0
- package/package.json +34 -0
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `descry` — the command-line entry point.
|
|
4
|
+
*
|
|
5
|
+
* The only command today is `init`. Nothing prints before argument parsing
|
|
6
|
+
* finishes, and a bad flag is a loud, immediate failure rather than a run
|
|
7
|
+
* that silently ignored it — the same instinct `descry-mcp`'s bin file
|
|
8
|
+
* states for its own argument handling.
|
|
9
|
+
*/
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=descry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descry.d.ts","sourceRoot":"","sources":["../../src/bin/descry.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* `descry` — the command-line entry point.
|
|
4
|
+
*
|
|
5
|
+
* The only command today is `init`. Nothing prints before argument parsing
|
|
6
|
+
* finishes, and a bad flag is a loud, immediate failure rather than a run
|
|
7
|
+
* that silently ignored it — the same instinct `descry-mcp`'s bin file
|
|
8
|
+
* states for its own argument handling.
|
|
9
|
+
*/
|
|
10
|
+
import process from "node:process";
|
|
11
|
+
import { runInit } from "../commands/init.js";
|
|
12
|
+
import { runViz } from "../commands/viz.js";
|
|
13
|
+
const USAGE = `descry — Descry's command-line surface
|
|
14
|
+
|
|
15
|
+
descry init [--workspace <name>] [--repo <name>] [repository-path]
|
|
16
|
+
descry viz [--port <number>] [repository-path]
|
|
17
|
+
|
|
18
|
+
Writes .descry/config.json with an explicit repo identity and, when given, a
|
|
19
|
+
workspace id every other repository in the same workspace must share
|
|
20
|
+
byte-identical. Also writes a packages declaration, but only when this
|
|
21
|
+
repository is a monorepo and nothing already declares one — never a pairing
|
|
22
|
+
between packages, which this command does not infer.
|
|
23
|
+
|
|
24
|
+
--workspace <name> the workspace id shared with other repositories.
|
|
25
|
+
Omit it for a single-repo project — nothing is
|
|
26
|
+
written and the output says so.
|
|
27
|
+
--repo <name> this repository's identity. Detected from
|
|
28
|
+
package.json#name or pyproject.toml's [project].name
|
|
29
|
+
when omitted, but always written explicitly either
|
|
30
|
+
way — never left to default at every future read.
|
|
31
|
+
repository-path defaults to the current directory.
|
|
32
|
+
|
|
33
|
+
descry viz serves a local, query-driven inspector over an already-built
|
|
34
|
+
graph (run analyze first). Search a symbol, see its neighbourhood — never
|
|
35
|
+
the whole graph at once.
|
|
36
|
+
|
|
37
|
+
--port <number> defaults to an OS-assigned free port.
|
|
38
|
+
`;
|
|
39
|
+
function parseInitArgs(args) {
|
|
40
|
+
let workspace;
|
|
41
|
+
let repo;
|
|
42
|
+
const positional = [];
|
|
43
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
44
|
+
const arg = args[i];
|
|
45
|
+
if (arg === "--help" || arg === "-h")
|
|
46
|
+
return { help: true, repoPath: process.cwd() };
|
|
47
|
+
if (arg === "--workspace") {
|
|
48
|
+
i += 1;
|
|
49
|
+
const value = args[i];
|
|
50
|
+
if (value === undefined)
|
|
51
|
+
throw new Error("--workspace needs a value");
|
|
52
|
+
workspace = value;
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
if (arg === "--repo") {
|
|
56
|
+
i += 1;
|
|
57
|
+
const value = args[i];
|
|
58
|
+
if (value === undefined)
|
|
59
|
+
throw new Error("--repo needs a value");
|
|
60
|
+
repo = value;
|
|
61
|
+
continue;
|
|
62
|
+
}
|
|
63
|
+
if (arg?.startsWith("--"))
|
|
64
|
+
throw new Error(`unknown flag "${arg}"`);
|
|
65
|
+
if (arg !== undefined)
|
|
66
|
+
positional.push(arg);
|
|
67
|
+
}
|
|
68
|
+
return {
|
|
69
|
+
help: false,
|
|
70
|
+
...(workspace === undefined ? {} : { workspace }),
|
|
71
|
+
...(repo === undefined ? {} : { repo }),
|
|
72
|
+
repoPath: positional[0] ?? process.cwd(),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
function parseVizArgs(args) {
|
|
76
|
+
let port;
|
|
77
|
+
const positional = [];
|
|
78
|
+
for (let i = 0; i < args.length; i += 1) {
|
|
79
|
+
const arg = args[i];
|
|
80
|
+
if (arg === "--help" || arg === "-h")
|
|
81
|
+
return { help: true, repoPath: process.cwd() };
|
|
82
|
+
if (arg === "--port") {
|
|
83
|
+
i += 1;
|
|
84
|
+
const value = args[i];
|
|
85
|
+
if (value === undefined)
|
|
86
|
+
throw new Error("--port needs a value");
|
|
87
|
+
const parsedPort = Number(value);
|
|
88
|
+
if (!Number.isInteger(parsedPort) || parsedPort <= 0)
|
|
89
|
+
throw new Error(`--port must be a positive integer, got "${value}"`);
|
|
90
|
+
port = parsedPort;
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
if (arg?.startsWith("--"))
|
|
94
|
+
throw new Error(`unknown flag "${arg}"`);
|
|
95
|
+
if (arg !== undefined)
|
|
96
|
+
positional.push(arg);
|
|
97
|
+
}
|
|
98
|
+
return { help: false, ...(port === undefined ? {} : { port }), repoPath: positional[0] ?? process.cwd() };
|
|
99
|
+
}
|
|
100
|
+
async function runInitCommand(rest) {
|
|
101
|
+
let parsed;
|
|
102
|
+
try {
|
|
103
|
+
parsed = parseInitArgs(rest);
|
|
104
|
+
}
|
|
105
|
+
catch (error) {
|
|
106
|
+
process.stderr.write(`descry init: ${error.message}\n\n${USAGE}`);
|
|
107
|
+
return 1;
|
|
108
|
+
}
|
|
109
|
+
if (parsed.help) {
|
|
110
|
+
process.stdout.write(USAGE);
|
|
111
|
+
return 0;
|
|
112
|
+
}
|
|
113
|
+
try {
|
|
114
|
+
const result = await runInit({
|
|
115
|
+
repoPath: parsed.repoPath,
|
|
116
|
+
...(parsed.workspace === undefined ? {} : { workspace: parsed.workspace }),
|
|
117
|
+
...(parsed.repo === undefined ? {} : { repo: parsed.repo }),
|
|
118
|
+
});
|
|
119
|
+
for (const line of result.lines)
|
|
120
|
+
process.stdout.write(`${line}\n`);
|
|
121
|
+
return 0;
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
process.stderr.write(`descry init: ${error.message}\n`);
|
|
125
|
+
return 1;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
async function runVizCommand(rest) {
|
|
129
|
+
let parsed;
|
|
130
|
+
try {
|
|
131
|
+
parsed = parseVizArgs(rest);
|
|
132
|
+
}
|
|
133
|
+
catch (error) {
|
|
134
|
+
process.stderr.write(`descry viz: ${error.message}\n\n${USAGE}`);
|
|
135
|
+
return 1;
|
|
136
|
+
}
|
|
137
|
+
if (parsed.help) {
|
|
138
|
+
process.stdout.write(USAGE);
|
|
139
|
+
return 0;
|
|
140
|
+
}
|
|
141
|
+
try {
|
|
142
|
+
const server = await runViz({
|
|
143
|
+
repoPath: parsed.repoPath,
|
|
144
|
+
...(parsed.port === undefined ? {} : { port: parsed.port }),
|
|
145
|
+
});
|
|
146
|
+
process.stdout.write(`descry viz: ${server.url}\n`);
|
|
147
|
+
process.stdout.write("Ctrl-C to stop.\n");
|
|
148
|
+
await new Promise((res) => process.once("SIGINT", () => res()));
|
|
149
|
+
await server.close();
|
|
150
|
+
return 0;
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
process.stderr.write(`descry viz: ${error.message}\n`);
|
|
154
|
+
return 1;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
async function main() {
|
|
158
|
+
const [command, ...rest] = process.argv.slice(2);
|
|
159
|
+
if (command === undefined || command === "--help" || command === "-h") {
|
|
160
|
+
process.stdout.write(USAGE);
|
|
161
|
+
return command === undefined ? 1 : 0;
|
|
162
|
+
}
|
|
163
|
+
if (command === "init")
|
|
164
|
+
return runInitCommand(rest);
|
|
165
|
+
if (command === "viz")
|
|
166
|
+
return runVizCommand(rest);
|
|
167
|
+
process.stderr.write(`descry: unknown command "${command}"\n\n${USAGE}`);
|
|
168
|
+
return 1;
|
|
169
|
+
}
|
|
170
|
+
process.exitCode = await main();
|
|
171
|
+
//# sourceMappingURL=descry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"descry.js","sourceRoot":"","sources":["../../src/bin/descry.ts"],"names":[],"mappings":";AACA;;;;;;;GAOG;AAEH,OAAO,OAAO,MAAM,cAAc,CAAC;AAEnC,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,MAAM,KAAK,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;CAyBb,CAAC;AASF,SAAS,aAAa,CAAC,IAAuB;IAC5C,IAAI,SAA6B,CAAC;IAClC,IAAI,IAAwB,CAAC;IAC7B,MAAM,UAAU,GAAa,EAAE,CAAC;IAEhC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC;QACxC,MAAM,GAAG,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,IAAI,GAAG,KAAK,QAAQ,IAAI,GAAG,KAAK,IAAI;YAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,Q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O,KAAK,SAAS,IAAI,OAAO,KAAK,QAAQ,IAAI,OAAO,KAAK,IAAI,EAAE,CAAC;QACtE,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QAC5B,OAAO,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IACvC,CAAC;IACD,IAAI,OAAO,KAAK,MAAM;QAAE,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;IACpD,IAAI,OAAO,KAAK,KAAK;QAAE,OAAO,aAAa,CAAC,IAAI,CAAC,CAAC;IAElD,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,4BAA4B,OAAO,QAAQ,KAAK,EAAE,CAAC,CAAC;IACzE,OAAO,CAAC,CAAC;AACX,CAAC;AAED,OAAO,CAAC,QAAQ,GAAG,MAAM,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `descry init` — write the two declarations a multi-repo run needs.
|
|
3
|
+
*
|
|
4
|
+
* Neither is inferred. The workspace id (`.descry/config.json`) is either
|
|
5
|
+
* given with `--workspace` or left unset; the package list a monorepo needs
|
|
6
|
+
* is read back from the manifests `resolveWorkspace` already knows how to
|
|
7
|
+
* read, never guessed here a second time. A pairing between two packages is
|
|
8
|
+
* never written by this command at all — `workspace.ts`'s header states why,
|
|
9
|
+
* and `init` does not relax it.
|
|
10
|
+
*
|
|
11
|
+
* ## What this prevents, and what it does not
|
|
12
|
+
*
|
|
13
|
+
* This is the declare-it-once half. The two guards that catch a run where
|
|
14
|
+
* nobody declared anything, or declared it wrong, live elsewhere: a
|
|
15
|
+
* zero-join warning at query time (`graph/build.ts`'s `NO_CROSS_REPO_JOIN`)
|
|
16
|
+
* and a workspace-mismatch check at write time from `batch.workspace`
|
|
17
|
+
* (`graph/writer.ts`). `init` does not duplicate either — it exists so a user
|
|
18
|
+
* who runs it never needs them.
|
|
19
|
+
*/
|
|
20
|
+
import { type DeclarationSource } from "@descryy/core";
|
|
21
|
+
export type RepoSource = "flag" | "package.json#name" | "pyproject.toml#name" | "directory basename";
|
|
22
|
+
export interface InitOptions {
|
|
23
|
+
readonly repoPath: string;
|
|
24
|
+
readonly workspace?: string | undefined;
|
|
25
|
+
readonly repo?: string | undefined;
|
|
26
|
+
}
|
|
27
|
+
export interface DeclarationWritten {
|
|
28
|
+
readonly path: string;
|
|
29
|
+
readonly source: DeclarationSource;
|
|
30
|
+
readonly packages: readonly string[];
|
|
31
|
+
}
|
|
32
|
+
export interface InitResult {
|
|
33
|
+
readonly configPath: string;
|
|
34
|
+
readonly repo: string;
|
|
35
|
+
readonly repoSource: RepoSource;
|
|
36
|
+
readonly workspace: string | undefined;
|
|
37
|
+
readonly declarationWritten: DeclarationWritten | null;
|
|
38
|
+
/** Why no packages declaration was written, when one was not. */
|
|
39
|
+
readonly declarationSkippedReason: string | null;
|
|
40
|
+
/** MK-3. The bare module specifiers written to `sources`, `null` when none were. */
|
|
41
|
+
readonly sourcesWritten: readonly string[] | null;
|
|
42
|
+
/** Why `sources` was not written, when it was not. */
|
|
43
|
+
readonly sourcesSkippedReason: string | null;
|
|
44
|
+
/** The exact report text — `bin/descry.ts` and tests share this rather than each formatting their own. */
|
|
45
|
+
readonly lines: readonly string[];
|
|
46
|
+
}
|
|
47
|
+
export declare function runInit(options: InitOptions): Promise<InitResult>;
|
|
48
|
+
//# sourceMappingURL=init.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAMH,OAAO,EAAoB,KAAK,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAGzE,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,mBAAmB,GAAG,qBAAqB,GAAG,oBAAoB,CAAC;AAErG,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IACnC,QAAQ,CAAC,QAAQ,EAAE,SAAS,MAAM,EAAE,CAAC;CACtC;AAED,MAAM,WAAW,UAAU;IACzB,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,SAAS,CAAC;IACvC,QAAQ,CAAC,kBAAkB,EAAE,kBAAkB,GAAG,IAAI,CAAC;IACvD,iEAAiE;IACjE,QAAQ,CAAC,wBAAwB,EAAE,MAAM,GAAG,IAAI,CAAC;IACjD,oFAAoF;IACpF,QAAQ,CAAC,cAAc,EAAE,SAAS,MAAM,EAAE,GAAG,IAAI,CAAC;IAClD,sDAAsD;IACtD,QAAQ,CAAC,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7C,0GAA0G;IAC1G,QAAQ,CAAC,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;CACnC;AA4GD,wBAAsB,OAAO,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,UAAU,CAAC,CAqGvE"}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `descry init` — write the two declarations a multi-repo run needs.
|
|
3
|
+
*
|
|
4
|
+
* Neither is inferred. The workspace id (`.descry/config.json`) is either
|
|
5
|
+
* given with `--workspace` or left unset; the package list a monorepo needs
|
|
6
|
+
* is read back from the manifests `resolveWorkspace` already knows how to
|
|
7
|
+
* read, never guessed here a second time. A pairing between two packages is
|
|
8
|
+
* never written by this command at all — `workspace.ts`'s header states why,
|
|
9
|
+
* and `init` does not relax it.
|
|
10
|
+
*
|
|
11
|
+
* ## What this prevents, and what it does not
|
|
12
|
+
*
|
|
13
|
+
* This is the declare-it-once half. The two guards that catch a run where
|
|
14
|
+
* nobody declared anything, or declared it wrong, live elsewhere: a
|
|
15
|
+
* zero-join warning at query time (`graph/build.ts`'s `NO_CROSS_REPO_JOIN`)
|
|
16
|
+
* and a workspace-mismatch check at write time from `batch.workspace`
|
|
17
|
+
* (`graph/writer.ts`). `init` does not duplicate either — it exists so a user
|
|
18
|
+
* who runs it never needs them.
|
|
19
|
+
*/
|
|
20
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
21
|
+
import { readFile, readdir, writeFile } from "node:fs/promises";
|
|
22
|
+
import { basename, join, resolve } from "node:path";
|
|
23
|
+
import { resolveWorkspace } from "@descryy/core";
|
|
24
|
+
import { loadConfig, writeConfig, writeSources } from "@descryy/mcp";
|
|
25
|
+
/**
|
|
26
|
+
* MK-3 — installed adapters, detected rather than named.
|
|
27
|
+
*
|
|
28
|
+
* `registry.ts`'s own header is explicit that this repository must never
|
|
29
|
+
* name a language: an adapter is anything installed under
|
|
30
|
+
* `@descryhq-wq/adapter-*`, found by listing a directory, not by matching a
|
|
31
|
+
* hand-maintained list that silently goes stale the next time
|
|
32
|
+
* `descry-adapters` ships a package this file has never heard of.
|
|
33
|
+
*
|
|
34
|
+
* Only `repoPath`'s own `node_modules` is checked — a workspace root that
|
|
35
|
+
* hoists dependencies elsewhere is a real gap, disclosed in
|
|
36
|
+
* `sourcesSkippedReason` rather than worked around by walking upward and
|
|
37
|
+
* risking a match against an unrelated monorepo's adapters.
|
|
38
|
+
*/
|
|
39
|
+
async function detectInstalledAdapters(repoPath) {
|
|
40
|
+
const scopeDir = join(repoPath, "node_modules", "@descryhq-wq");
|
|
41
|
+
let entries;
|
|
42
|
+
try {
|
|
43
|
+
entries = (await readdir(scopeDir, { withFileTypes: true }))
|
|
44
|
+
.filter((e) => (e.isDirectory() || e.isSymbolicLink()) && e.name.startsWith("adapter-"))
|
|
45
|
+
.map((e) => e.name);
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return [];
|
|
49
|
+
}
|
|
50
|
+
return entries.sort().map((name) => `@descryhq-wq/${name}`);
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* `[project]`'s `name`, read as narrowly as `workspace.ts` reads
|
|
54
|
+
* `[tool.descry]` — this is not a TOML parser, and a `name` key belonging to
|
|
55
|
+
* some other table (a dependency, `[tool.poetry]`) must not be picked up by
|
|
56
|
+
* accident.
|
|
57
|
+
*/
|
|
58
|
+
function readPyprojectProjectName(repoPath) {
|
|
59
|
+
const path = join(repoPath, "pyproject.toml");
|
|
60
|
+
if (!existsSync(path))
|
|
61
|
+
return undefined;
|
|
62
|
+
let text;
|
|
63
|
+
try {
|
|
64
|
+
text = readFileSync(path, "utf8");
|
|
65
|
+
}
|
|
66
|
+
catch {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
let inProjectTable = false;
|
|
70
|
+
for (const raw of text.split("\n")) {
|
|
71
|
+
const line = raw.trim();
|
|
72
|
+
if (/^\[.*\]$/.test(line)) {
|
|
73
|
+
inProjectTable = line === "[project]";
|
|
74
|
+
continue;
|
|
75
|
+
}
|
|
76
|
+
if (!inProjectTable)
|
|
77
|
+
continue;
|
|
78
|
+
const match = /^name\s*=\s*"([^"]*)"\s*$/.exec(line);
|
|
79
|
+
if (match?.[1] !== undefined && match[1] !== "")
|
|
80
|
+
return match[1];
|
|
81
|
+
}
|
|
82
|
+
return undefined;
|
|
83
|
+
}
|
|
84
|
+
function detectRepoName(repoPath) {
|
|
85
|
+
const pkgJsonPath = join(repoPath, "package.json");
|
|
86
|
+
if (existsSync(pkgJsonPath)) {
|
|
87
|
+
try {
|
|
88
|
+
const parsed = JSON.parse(readFileSync(pkgJsonPath, "utf8"));
|
|
89
|
+
if (typeof parsed.name === "string" && parsed.name !== "") {
|
|
90
|
+
return { name: parsed.name, source: "package.json#name" };
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
catch {
|
|
94
|
+
// fall through
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
const pyprojectName = readPyprojectProjectName(repoPath);
|
|
98
|
+
if (pyprojectName !== undefined)
|
|
99
|
+
return { name: pyprojectName, source: "pyproject.toml#name" };
|
|
100
|
+
return { name: basename(resolve(repoPath)), source: "directory basename" };
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Packages only, by preference: an existing manifest over a new root file.
|
|
104
|
+
* `null` means a declaration slot exists but this reader would not trust
|
|
105
|
+
* itself to merge into it — left untouched rather than risking a duplicate
|
|
106
|
+
* `[tool.descry]` table or a silently overwritten key.
|
|
107
|
+
*/
|
|
108
|
+
async function writePackagesDeclaration(repoPath, packages) {
|
|
109
|
+
const pkgJsonPath = join(repoPath, "package.json");
|
|
110
|
+
if (existsSync(pkgJsonPath)) {
|
|
111
|
+
const parsed = JSON.parse(await readFile(pkgJsonPath, "utf8"));
|
|
112
|
+
if (parsed.descry !== undefined)
|
|
113
|
+
return null;
|
|
114
|
+
parsed.descry = { packages: [...packages] };
|
|
115
|
+
await writeFile(pkgJsonPath, `${JSON.stringify(parsed, null, 2)}\n`, "utf8");
|
|
116
|
+
return { path: pkgJsonPath, source: "package.json#descry" };
|
|
117
|
+
}
|
|
118
|
+
const pyprojectPath = join(repoPath, "pyproject.toml");
|
|
119
|
+
if (existsSync(pyprojectPath)) {
|
|
120
|
+
const text = await readFile(pyprojectPath, "utf8");
|
|
121
|
+
if (text.includes("[tool.descry]"))
|
|
122
|
+
return null;
|
|
123
|
+
const table = `\n[tool.descry]\npackages = [${packages.map((p) => `"${p}"`).join(", ")}]\n`;
|
|
124
|
+
await writeFile(pyprojectPath, `${text.replace(/\n*$/, "\n")}${table}`, "utf8");
|
|
125
|
+
return { path: pyprojectPath, source: "pyproject.toml#tool.descry" };
|
|
126
|
+
}
|
|
127
|
+
const descryJsonPath = join(repoPath, "descry.json");
|
|
128
|
+
await writeFile(descryJsonPath, `${JSON.stringify({ packages: [...packages] }, null, 2)}\n`, "utf8");
|
|
129
|
+
return { path: descryJsonPath, source: "descry.json" };
|
|
130
|
+
}
|
|
131
|
+
export async function runInit(options) {
|
|
132
|
+
const repoPath = resolve(options.repoPath);
|
|
133
|
+
const lines = [];
|
|
134
|
+
const repo = options.repo !== undefined && options.repo !== ""
|
|
135
|
+
? { name: options.repo, source: "flag" }
|
|
136
|
+
: detectRepoName(repoPath);
|
|
137
|
+
const config = await writeConfig(repoPath, {
|
|
138
|
+
repo: repo.name,
|
|
139
|
+
...(options.workspace === undefined ? {} : { workspace: options.workspace }),
|
|
140
|
+
});
|
|
141
|
+
lines.push(`wrote ${config.path}`);
|
|
142
|
+
lines.push(` repo: "${repo.name}" (from ${repo.source})`);
|
|
143
|
+
if (options.workspace !== undefined) {
|
|
144
|
+
lines.push(` workspace: "${options.workspace}"`);
|
|
145
|
+
if (config.previousWorkspace !== undefined && config.previousWorkspace !== options.workspace) {
|
|
146
|
+
lines.push(` (replaced previous workspace "${config.previousWorkspace}")`);
|
|
147
|
+
}
|
|
148
|
+
lines.push("");
|
|
149
|
+
lines.push(`WORKSPACE ID: ${options.workspace}`);
|
|
150
|
+
lines.push("Write this exact string, byte-identical, into every other repository that should join " +
|
|
151
|
+
"this one's graph. A single differing character produces a graph that joins nothing, silently.");
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
lines.push(" workspace: not set");
|
|
155
|
+
lines.push("");
|
|
156
|
+
lines.push("Single-repo project — no workspace id written. Nothing here can join another repository's " +
|
|
157
|
+
"graph, which is correct until there is a second repository to join. Run again with " +
|
|
158
|
+
"--workspace <name> when there is.");
|
|
159
|
+
}
|
|
160
|
+
const declaration = resolveWorkspace(repoPath);
|
|
161
|
+
let declarationWritten = null;
|
|
162
|
+
let declarationSkippedReason = null;
|
|
163
|
+
lines.push("");
|
|
164
|
+
if (declaration.packages.length <= 1) {
|
|
165
|
+
declarationSkippedReason = "single package — no packages declaration needed.";
|
|
166
|
+
lines.push(declarationSkippedReason);
|
|
167
|
+
}
|
|
168
|
+
else if (declaration.declarationSource !== "none") {
|
|
169
|
+
declarationSkippedReason = `packages already declared via ${declaration.declarationSource} — left untouched.`;
|
|
170
|
+
lines.push(declarationSkippedReason);
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const written = await writePackagesDeclaration(repoPath, declaration.packages);
|
|
174
|
+
if (written === null) {
|
|
175
|
+
declarationSkippedReason =
|
|
176
|
+
"a packages declaration slot exists but could not be read safely, so nothing was written " +
|
|
177
|
+
'to it — add "descry": { "packages": [...] } (or the pyproject.toml [tool.descry] table) by hand.';
|
|
178
|
+
lines.push(declarationSkippedReason);
|
|
179
|
+
}
|
|
180
|
+
else {
|
|
181
|
+
declarationWritten = { path: written.path, source: written.source, packages: declaration.packages };
|
|
182
|
+
lines.push(`wrote ${written.path} (${declaration.packages.length} package(s): ${declaration.packages.join(", ")})`);
|
|
183
|
+
lines.push("No pairing was written. A pairing between two packages is never inferred from their names — " +
|
|
184
|
+
"declare it by hand if two packages here are meant to join, or let a real USES_API/SERVES_API " +
|
|
185
|
+
"edge at R3 discover it.");
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
lines.push("");
|
|
189
|
+
let sourcesWritten = null;
|
|
190
|
+
let sourcesSkippedReason = null;
|
|
191
|
+
const existingSources = (await loadConfig(repoPath)).sources;
|
|
192
|
+
if (existingSources.length > 0) {
|
|
193
|
+
sourcesSkippedReason = `sources already configured (${existingSources.length}) — left untouched.`;
|
|
194
|
+
lines.push(sourcesSkippedReason);
|
|
195
|
+
}
|
|
196
|
+
else {
|
|
197
|
+
const detected = await detectInstalledAdapters(repoPath);
|
|
198
|
+
if (detected.length === 0) {
|
|
199
|
+
sourcesSkippedReason =
|
|
200
|
+
"no adapter found under node_modules/@descryhq-wq — install one " +
|
|
201
|
+
'("npm install @descryhq-wq/adapter-<name>") and run init again, or add "sources" to ' +
|
|
202
|
+
".descry/config.json by hand.";
|
|
203
|
+
lines.push(sourcesSkippedReason);
|
|
204
|
+
}
|
|
205
|
+
else {
|
|
206
|
+
await writeSources(repoPath, detected);
|
|
207
|
+
sourcesWritten = detected;
|
|
208
|
+
lines.push(`wrote sources: ${detected.length} adapter(s) detected — ${detected.join(", ")}`);
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return {
|
|
212
|
+
configPath: config.path,
|
|
213
|
+
repo: repo.name,
|
|
214
|
+
repoSource: repo.source,
|
|
215
|
+
workspace: options.workspace,
|
|
216
|
+
declarationWritten,
|
|
217
|
+
declarationSkippedReason,
|
|
218
|
+
sourcesWritten,
|
|
219
|
+
sourcesSkippedReason,
|
|
220
|
+
lines,
|
|
221
|
+
};
|
|
222
|
+
}
|
|
223
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpD,OAAO,EAAE,gBAAgB,EAA0B,MAAM,eAAe,CAAC;AACzE,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAgCrE;;;;;;;;;;;;;GAaG;AACH,KAAK,UAAU,uBAAuB,CAAC,QAAgB;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,EAAE,cAAc,EAAE,cAAc,CAAC,CAAC;IAChE,IAAI,OAAiB,CAAC;IACtB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AAC;YACvC,cAAc,GAAG,QAAQ,CAAC;YAC1B,KAAK,CAAC,IAAI,CAAC,kBAAkB,QAAQ,CAAC,MAAM,0BAA0B,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAC/F,CAAC;IACH,CAAC;IAED,OAAO;QACL,UAAU,EAAE,MAAM,CAAC,IAAI;QACvB,IAAI,EAAE,IAAI,CAAC,IAAI;QACf,UAAU,EAAE,IAAI,CAAC,MAAM;QACvB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,kBAAkB;QAClB,wBAAwB;QACxB,cAAc;QACd,oBAAoB;QACpB,KAAK;KACN,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `descry viz` — resolve the graph path the same way every other front door
|
|
3
|
+
* does (`.descry/config.json`'s `graph` field, defaulting like `Session`
|
|
4
|
+
* does) and hand it to `@descryy/viz`. This command owns argument parsing and
|
|
5
|
+
* path resolution only; it reads no graph itself.
|
|
6
|
+
*/
|
|
7
|
+
export interface RunVizOptions {
|
|
8
|
+
readonly repoPath: string;
|
|
9
|
+
readonly port?: number | undefined;
|
|
10
|
+
}
|
|
11
|
+
export interface RunVizResult {
|
|
12
|
+
readonly url: string;
|
|
13
|
+
readonly close: () => Promise<void>;
|
|
14
|
+
}
|
|
15
|
+
export declare function runViz(options: RunVizOptions): Promise<RunVizResult>;
|
|
16
|
+
//# sourceMappingURL=viz.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viz.d.ts","sourceRoot":"","sources":["../../src/commands/viz.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACpC;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;CACrC;AAED,wBAAsB,MAAM,CAAC,OAAO,EAAE,aAAa,GAAG,OAAO,CAAC,YAAY,CAAC,CAW1E"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `descry viz` — resolve the graph path the same way every other front door
|
|
3
|
+
* does (`.descry/config.json`'s `graph` field, defaulting like `Session`
|
|
4
|
+
* does) and hand it to `@descryy/viz`. This command owns argument parsing and
|
|
5
|
+
* path resolution only; it reads no graph itself.
|
|
6
|
+
*/
|
|
7
|
+
import { isAbsolute, join, resolve } from "node:path";
|
|
8
|
+
import { loadConfig } from "@descryy/mcp";
|
|
9
|
+
import { startVizServer } from "@descryy/viz";
|
|
10
|
+
export async function runViz(options) {
|
|
11
|
+
const repoPath = resolve(options.repoPath);
|
|
12
|
+
const config = await loadConfig(repoPath);
|
|
13
|
+
const graphPath = isAbsolute(config.graph) ? config.graph : join(repoPath, config.graph);
|
|
14
|
+
const server = await startVizServer({
|
|
15
|
+
graphPath,
|
|
16
|
+
...(options.port === undefined ? {} : { port: options.port }),
|
|
17
|
+
});
|
|
18
|
+
return { url: server.url, close: server.close };
|
|
19
|
+
}
|
|
20
|
+
//# sourceMappingURL=viz.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viz.js","sourceRoot":"","sources":["../../src/commands/viz.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEtD,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,cAAc,EAAE,MAAM,cAAc,CAAC;AAY9C,MAAM,CAAC,KAAK,UAAU,MAAM,CAAC,OAAsB;IACjD,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC3C,MAAM,MAAM,GAAG,MAAM,UAAU,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;IAEzF,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC;QAClC,SAAS;QACT,GAAG,CAAC,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC;KAC9D,CAAC,CAAC;IAEH,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,CAAC;AAClD,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,WAAW,EAAE,KAAK,UAAU,EAAE,KAAK,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,oBAAoB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAA+E,MAAM,oBAAoB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@descryy/cli",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"description": "Descry's command-line surface. First command is `init`, which writes the declarations a multi-repo run needs — the workspace id in .descry/config.json, and a package/pairing declaration when the repo is a monorepo. Neither is ever inferred.",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=22.5"
|
|
9
|
+
},
|
|
10
|
+
"exports": {
|
|
11
|
+
".": {
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"bin": {
|
|
17
|
+
"descry": "./dist/bin/descry.js"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist"
|
|
21
|
+
],
|
|
22
|
+
"publishConfig": {
|
|
23
|
+
"registry": "https://registry.npmjs.org",
|
|
24
|
+
"access": "public"
|
|
25
|
+
},
|
|
26
|
+
"scripts": {
|
|
27
|
+
"build": "tsc -b"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@descryy/core": "0.1.1",
|
|
31
|
+
"@descryy/mcp": "0.1.1",
|
|
32
|
+
"@descryy/viz": "0.1.0"
|
|
33
|
+
}
|
|
34
|
+
}
|