@ttsc/graph 0.18.3 → 0.18.4

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 CHANGED
@@ -47,6 +47,7 @@ The whole MCP surface is one tool, `inspect_typescript_graph`. You ask in plain
47
47
 
48
48
  - **An index, not source bodies.** It returns names, edges, signatures, and spans, never code, so the response stays flat as the repository grows.
49
49
  - **Built on the real compiler.** It reads the program `ttsc` type-checked, so `tsconfig` aliases, pnpm monorepos, symlinks, and re-exports resolve exactly, where a text parser can only guess.
50
+ - **Current within one agent session.** Before each graph operation it checks the config, root-file set, module-resolution inputs, and source contents. Unchanged calls reuse the warm graph; source edits update the resident compiler incrementally; config, file-addition, deletion, and resolution changes reload safely.
50
51
  - **It does not force itself.** It states when the graph is the right source and offers a first-class `escape` for everything else.
51
52
  - **Errors and lint too.** `tsc` compile errors and `@ttsc/lint` and plugin (typia, nestia) findings ride the same graph, so "what is broken here?" answers from one index.
52
53
 
@@ -1,6 +1,6 @@
1
1
  import { TtscGraphMemory } from "./model/TtscGraphMemory";
2
2
  import { ITtscGraphApplication } from "./structures/ITtscGraphApplication";
3
- export type TtscGraphSource = TtscGraphMemory | (() => TtscGraphMemory);
3
+ export type TtscGraphSource = TtscGraphMemory | (() => TtscGraphMemory | Promise<TtscGraphMemory>);
4
4
  /**
5
5
  * The MCP tool surface as a plain class over the resident
6
6
  * {@link TtscGraphMemory}.
@@ -12,13 +12,14 @@ export type TtscGraphSource = TtscGraphMemory | (() => TtscGraphMemory);
12
12
  * The method delegates to the pure graph functions in `./server`, which are
13
13
  * unit-testable without a transport; this class only binds them to the graph.
14
14
  *
15
- * Every method answers from the resident graph; none recompiles. Output is kept
15
+ * Every method answers from the current resident graph. The source may refresh
16
+ * that graph before the operation when project files changed. Output is kept
16
17
  * compact and bounded so a model can read structure without a file read, which
17
18
  * is the token win the redesign exists for.
18
19
  */
19
20
  export declare class TtscGraphApplication implements ITtscGraphApplication {
20
21
  private readonly graph;
21
22
  constructor(source: TtscGraphSource);
22
- inspect_typescript_graph(props: ITtscGraphApplication.IProps): ITtscGraphApplication.IResult;
23
+ inspect_typescript_graph(props: ITtscGraphApplication.IProps): Promise<ITtscGraphApplication.IResult>;
23
24
  private escape;
24
25
  }
@@ -19,7 +19,8 @@ const runTrace_1 = require("./server/runTrace");
19
19
  * The method delegates to the pure graph functions in `./server`, which are
20
20
  * unit-testable without a transport; this class only binds them to the graph.
21
21
  *
22
- * Every method answers from the resident graph; none recompiles. Output is kept
22
+ * Every method answers from the current resident graph. The source may refresh
23
+ * that graph before the operation when project files changed. Output is kept
23
24
  * compact and bounded so a model can read structure without a file read, which
24
25
  * is the token win the redesign exists for.
25
26
  */
@@ -28,7 +29,7 @@ class TtscGraphApplication {
28
29
  constructor(source) {
29
30
  this.graph = typeof source === "function" ? source : () => source;
30
31
  }
31
- inspect_typescript_graph(props) {
32
+ async inspect_typescript_graph(props) {
32
33
  if (props.request.type === "escape") {
33
34
  const result = this.escape(props.request.reason);
34
35
  if (props.request.nextStep !== undefined) {
@@ -38,30 +39,31 @@ class TtscGraphApplication {
38
39
  result,
39
40
  };
40
41
  }
42
+ const graph = await this.graph();
41
43
  switch (props.request.type) {
42
44
  case "entrypoints":
43
45
  return {
44
- result: (0, runEntrypoints_1.runEntrypoints)(this.graph(), props.request),
46
+ result: (0, runEntrypoints_1.runEntrypoints)(graph, props.request),
45
47
  };
46
48
  case "lookup":
47
49
  return {
48
- result: (0, runLookup_1.runLookup)(this.graph(), props.request),
50
+ result: (0, runLookup_1.runLookup)(graph, props.request),
49
51
  };
50
52
  case "trace":
51
53
  return {
52
- result: (0, runTrace_1.runTrace)(this.graph(), props.request),
54
+ result: (0, runTrace_1.runTrace)(graph, props.request),
53
55
  };
54
56
  case "details":
55
57
  return {
56
- result: (0, runDetails_1.runDetails)(this.graph(), props.request),
58
+ result: (0, runDetails_1.runDetails)(graph, props.request),
57
59
  };
58
60
  case "overview":
59
61
  return {
60
- result: (0, runOverview_1.runOverview)(this.graph(), props.request),
62
+ result: (0, runOverview_1.runOverview)(graph, props.request),
61
63
  };
62
64
  case "tour":
63
65
  return {
64
- result: (0, runTour_1.runTour)(this.graph(), props.request),
66
+ result: (0, runTour_1.runTour)(graph, props.request),
65
67
  };
66
68
  default:
67
69
  props.request;
@@ -1 +1 @@
1
- {"version":3,"file":"TtscGraphApplication.js","sourceRoot":"","sources":["../src/TtscGraphApplication.ts"],"names":[],"mappings":";;;AACA,sDAA+D;AAC/D,oDAAiD;AACjD,4DAAyD;AACzD,kDAA+C;AAC/C,sDAAmD;AACnD,8CAA2C;AAC3C,gDAA6C;AAM7C;;;;;;;;;;;;;;GAcG;AACH;IACmB,KAAK,CAAwB;IAE9C,YAAmB,MAAuB;QACxC,IAAI,CAAC,KAAK,GAAG,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IACpE,CAAC;IAEM,wBAAwB,CAC7B,KAAmC;QAEnC,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;YACjD,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,KAAK,SAAS,EAAE,CAAC;gBACzC,MAAM,CAAC,QAAQ,GAAG,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;YAC3C,CAAC;YACD,OAAO;gBACL,MAAM;aACP,CAAC;QACJ,CAAC;QACD,QAAQ,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,CAAC;YAC3B,KAAK,aAAa;gBAChB,OAAO;oBACL,MAAM,EAAE,IAAA,+BAAc,EAAC,IAAI,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,OAAO,CAAC;iBACpD,CAAC;YACJ,KAAK,QAAQ;gBACX,OAAO;oBACL,MAAM,EAAE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U,EAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;iBACzC,CAAC;YACJ,KAAK,UAAU;gBACb,OAAO;oBACL,MAAM,EAAE,IAAA,yBAAW,EAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;iBAC1C,CAAC;YACJ,KAAK,MAAM;gBACT,OAAO;oBACL,MAAM,EAAE,IAAA,iBAAO,EAAC,KAAK,EAAE,KAAK,CAAC,OAAO,CAAC;iBACtC,CAAC;YACJ;gBACE,KAAK,CAAC,OAAuB,CAAC;gBAC9B,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;QAClD,CAAC;IACH,CAAC;IAEO,MAAM,CACZ,MAAc,EACd,QAAiB,EACjB,MAAM,GAAqC,SAAS;QAEpD,OAAO;YACL,IAAI,EAAE,QAAQ;YACd,OAAO,EAAE,IAAI;YACb,MAAM;YACN,IAAI,EAAE,IAAA,wBAAU,EACd,MAAM,EACN,QAAQ;gBACN,8DAA8D,CACjE;YACD,KAAK,EAAE,IAAA,yBAAW,EAChB,qFAAqF,CACtF;YACD,GAAG,CAAC,QAAQ,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAChD,CAAC;IACJ,CAAC;CACF"}
package/lib/index.d.ts CHANGED
@@ -4,9 +4,9 @@
4
4
  * - `view`: JS-orchestrated 3D viewer (dump -> reduce -> serve -> open).
5
5
  * - `dump`: pass through to the native `ttscgraph dump`, which prints the whole
6
6
  * graph as JSON for piping or the viewer.
7
- * - Default: serve the MCP graph over stdio. The TypeScript server runs
8
- * `ttscgraph dump` once to build the resident graph, then answers tool calls
9
- * from memory; the agent's MCP client speaks JSON-RPC over this process's
10
- * stdin/stdout. The process stays alive on the stdio transport.
7
+ * - Default: serve the MCP graph over stdio. The TypeScript server keeps a native
8
+ * incremental compiler session resident, checks the disk snapshot before each
9
+ * graph operation, and reuses the in-memory graph when unchanged; the agent's
10
+ * MCP client speaks JSON-RPC over this process's stdin/stdout.
11
11
  */
12
12
  export declare function runGraph(argv?: readonly string[]): number | void;
package/lib/index.js CHANGED
@@ -40,10 +40,10 @@ function parseProjectArgs(argv) {
40
40
  * - `view`: JS-orchestrated 3D viewer (dump -> reduce -> serve -> open).
41
41
  * - `dump`: pass through to the native `ttscgraph dump`, which prints the whole
42
42
  * graph as JSON for piping or the viewer.
43
- * - Default: serve the MCP graph over stdio. The TypeScript server runs
44
- * `ttscgraph dump` once to build the resident graph, then answers tool calls
45
- * from memory; the agent's MCP client speaks JSON-RPC over this process's
46
- * stdin/stdout. The process stays alive on the stdio transport.
43
+ * - Default: serve the MCP graph over stdio. The TypeScript server keeps a native
44
+ * incremental compiler session resident, checks the disk snapshot before each
45
+ * graph operation, and reuses the in-memory graph when unchanged; the agent's
46
+ * MCP client speaks JSON-RPC over this process's stdin/stdout.
47
47
  */
48
48
  function runGraph(argv = process.argv.slice(2)) {
49
49
  if (argv[0] === "view")
@@ -0,0 +1,36 @@
1
+ import { TtscGraphMemory } from "./TtscGraphMemory";
2
+ /**
3
+ * Resident bridge to `ttscgraph serve`.
4
+ *
5
+ * Every graph request first asks the native session for the current disk
6
+ * snapshot. Unchanged requests reuse the existing {@link TtscGraphMemory}; an
7
+ * edited source reuses tsgo's resident Program through `driver.Session`, while
8
+ * config and root-file-set changes force a safe full reload.
9
+ */
10
+ export declare class TtscGraphSession {
11
+ private readonly cwd;
12
+ private readonly tsconfig;
13
+ private readonly binary;
14
+ private child;
15
+ private stderr;
16
+ private nextId;
17
+ private readonly pending;
18
+ private queue;
19
+ private current;
20
+ private closed;
21
+ constructor(options: {
22
+ cwd: string;
23
+ tsconfig: string;
24
+ binary?: string;
25
+ });
26
+ /** Return a graph for the current disk snapshot, serialized per tool call. */
27
+ graph(): Promise<TtscGraphMemory>;
28
+ /** Close the native session. Safe to call more than once. */
29
+ close(): void;
30
+ private refresh;
31
+ private request;
32
+ private ensureChild;
33
+ private onLine;
34
+ private failChild;
35
+ private failPending;
36
+ }