cwtools-shared 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.
Files changed (53) hide show
  1. package/dist/generated/mcpTools.d.ts +1112 -0
  2. package/dist/generated/mcpTools.js +1247 -0
  3. package/dist/host/diagnostics.d.ts +41 -0
  4. package/dist/host/diagnostics.js +18 -0
  5. package/dist/host/filesystem.d.ts +18 -0
  6. package/dist/host/filesystem.js +2 -0
  7. package/dist/host/hostServices.d.ts +49 -0
  8. package/dist/host/hostServices.js +2 -0
  9. package/dist/host/indexing.d.ts +54 -0
  10. package/dist/host/indexing.js +2 -0
  11. package/dist/host/lsp.d.ts +8 -0
  12. package/dist/host/lsp.js +27 -0
  13. package/dist/host/readiness.d.ts +11 -0
  14. package/dist/host/readiness.js +71 -0
  15. package/dist/host/vanillaCache.d.ts +12 -0
  16. package/dist/host/vanillaCache.js +56 -0
  17. package/dist/host/vsCodeHostServices.d.ts +27 -0
  18. package/dist/host/vsCodeHostServices.js +30 -0
  19. package/dist/index.d.ts +25 -0
  20. package/dist/index.js +41 -0
  21. package/dist/knowledge/diagnosticRouting.d.ts +13 -0
  22. package/dist/knowledge/diagnosticRouting.js +57 -0
  23. package/dist/knowledge/gameKnowledge.d.ts +20 -0
  24. package/dist/knowledge/gameKnowledge.js +52 -0
  25. package/dist/knowledge/rules.d.ts +162 -0
  26. package/dist/knowledge/rules.js +1383 -0
  27. package/dist/knowledge/workflowHints.d.ts +11 -0
  28. package/dist/knowledge/workflowHints.js +31 -0
  29. package/dist/project/knowledge.d.ts +15 -0
  30. package/dist/project/knowledge.js +209 -0
  31. package/dist/project/profile.d.ts +45 -0
  32. package/dist/project/profile.js +177 -0
  33. package/dist/safety/localisation.d.ts +33 -0
  34. package/dist/safety/localisation.js +105 -0
  35. package/dist/safety/paths.d.ts +21 -0
  36. package/dist/safety/paths.js +122 -0
  37. package/dist/safety/writes.d.ts +3 -0
  38. package/dist/safety/writes.js +19 -0
  39. package/dist/tools/mcpSchema.d.ts +5 -0
  40. package/dist/tools/mcpSchema.js +19 -0
  41. package/dist/tools/names.d.ts +6 -0
  42. package/dist/tools/names.js +51 -0
  43. package/dist/tools/pdxBlock.d.ts +17 -0
  44. package/dist/tools/pdxBlock.js +140 -0
  45. package/dist/tools/registry.d.ts +10 -0
  46. package/dist/tools/registry.js +2 -0
  47. package/dist/tools/schema.d.ts +36 -0
  48. package/dist/tools/schema.js +21 -0
  49. package/dist/tools/symbols.d.ts +60 -0
  50. package/dist/tools/symbols.js +625 -0
  51. package/dist/tools/toolHandlers.d.ts +4 -0
  52. package/dist/tools/toolHandlers.js +291 -0
  53. package/package.json +24 -0
@@ -0,0 +1,41 @@
1
+ export type DiagnosticSeverity = 'error' | 'warning' | 'information' | 'hint';
2
+ export type DiagnosticsFreshness = 'fresh' | 'pending' | 'stale' | 'unavailable';
3
+ export interface DiagnosticRecord {
4
+ file?: string;
5
+ line?: number;
6
+ column?: number;
7
+ endLine?: number;
8
+ endColumn?: number;
9
+ severity: DiagnosticSeverity;
10
+ code?: string;
11
+ message: string;
12
+ source?: string;
13
+ }
14
+ export interface DiagnosticsFilter {
15
+ file?: string;
16
+ severity?: DiagnosticSeverity;
17
+ limit?: number;
18
+ }
19
+ export interface DiagnosticsQueryResult {
20
+ ok: boolean;
21
+ status: DiagnosticsFreshness;
22
+ diagnostics: DiagnosticRecord[];
23
+ totalCount?: number;
24
+ truncated?: boolean;
25
+ suppressedCount?: number;
26
+ freshness?: {
27
+ value: DiagnosticsFreshness;
28
+ pendingKinds: string[];
29
+ validatedVersion?: number;
30
+ epoch?: number;
31
+ updatedAt?: number;
32
+ };
33
+ error?: {
34
+ code: string;
35
+ message: string;
36
+ };
37
+ }
38
+ export interface DiagnosticsHost {
39
+ getDiagnostics(filter?: DiagnosticsFilter): Promise<DiagnosticsQueryResult>;
40
+ }
41
+ export declare function createUnavailableDiagnosticsHost(message?: string): DiagnosticsHost;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createUnavailableDiagnosticsHost = createUnavailableDiagnosticsHost;
4
+ function createUnavailableDiagnosticsHost(message = 'Diagnostics are not available without an LSP connection.') {
5
+ return {
6
+ async getDiagnostics() {
7
+ return {
8
+ ok: false,
9
+ status: 'unavailable',
10
+ diagnostics: [],
11
+ error: {
12
+ code: 'diagnostics_unavailable',
13
+ message,
14
+ },
15
+ };
16
+ },
17
+ };
18
+ }
@@ -0,0 +1,18 @@
1
+ export interface ReadTextFileResult {
2
+ content: string;
3
+ hasBom: boolean;
4
+ exists: boolean;
5
+ }
6
+ export interface DirectoryEntry {
7
+ name: string;
8
+ type: 'file' | 'directory';
9
+ size?: number;
10
+ }
11
+ export interface FilesystemHost {
12
+ readTextFile(path: string): Promise<ReadTextFileResult>;
13
+ writeTextFile(path: string, content: string): Promise<void>;
14
+ list(path: string): Promise<DirectoryEntry[]>;
15
+ glob(pattern: string, options?: {
16
+ limit?: number;
17
+ }): Promise<string[]>;
18
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,49 @@
1
+ import type { DiagnosticsHost } from './diagnostics';
2
+ import type { FilesystemHost } from './filesystem';
3
+ import type { IndexHost } from './indexing';
4
+ import type { LspHost } from './lsp';
5
+ import type { VanillaCacheStatus } from './vanillaCache';
6
+ export type HostLogLevel = 'debug' | 'info' | 'warn' | 'error';
7
+ export interface ProjectProfileHost {
8
+ readProfile(): Promise<unknown | null>;
9
+ }
10
+ export interface GameKnowledgeHost {
11
+ queryProfile?(args?: unknown): Promise<unknown>;
12
+ queryHints?(args?: unknown): Promise<unknown>;
13
+ queryDiagnosticKnowledge?(args?: unknown): Promise<unknown>;
14
+ }
15
+ export interface CompletionHost {
16
+ getCompletionContext(args: unknown): Promise<unknown>;
17
+ }
18
+ export interface RulesConfigHost {
19
+ gameId?: string;
20
+ configDirs?: string[];
21
+ readTextFile?(filePath: string): Promise<{
22
+ content: string;
23
+ hasBom?: boolean;
24
+ exists: boolean;
25
+ }>;
26
+ listCwtFiles?(root: string, options?: {
27
+ limit?: number;
28
+ }): Promise<string[]>;
29
+ }
30
+ export interface HostServices {
31
+ workspaceRoot: string;
32
+ readonlyMode: boolean;
33
+ writesEnabled: boolean;
34
+ allowedWriteTools?: ReadonlySet<string>;
35
+ lsp: LspHost;
36
+ diagnostics: DiagnosticsHost;
37
+ filesystem: FilesystemHost;
38
+ indexing?: IndexHost;
39
+ projectProfile?: ProjectProfileHost;
40
+ knowledge?: GameKnowledgeHost;
41
+ completion?: CompletionHost;
42
+ rules?: RulesConfigHost;
43
+ vanillaCache?: VanillaCacheStatus;
44
+ projectSupported?: boolean;
45
+ projectSupportReason?: string;
46
+ now(): number;
47
+ log(level: HostLogLevel, message: string, data?: unknown): void;
48
+ dispose?(): void;
49
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,54 @@
1
+ export interface WorkspaceIndexQuery {
2
+ name?: string;
3
+ kind?: string;
4
+ category?: string;
5
+ source?: 'script' | 'asset' | 'gui';
6
+ origin?: 'workspace' | 'vanilla' | 'both';
7
+ directory?: string;
8
+ prefix?: boolean;
9
+ exact?: boolean;
10
+ includeReferences?: boolean;
11
+ limit?: number;
12
+ }
13
+ export interface WorkspaceIndexEntry {
14
+ name: string;
15
+ kind: string;
16
+ file: string;
17
+ line: number;
18
+ source: 'script' | 'asset' | 'gui';
19
+ origin: 'workspace' | 'vanilla';
20
+ category?: string;
21
+ container?: string;
22
+ updatedAt?: number;
23
+ fileVersion?: number;
24
+ }
25
+ export interface LocalisationIndexQuery {
26
+ key?: string;
27
+ language?: string;
28
+ prefix?: boolean;
29
+ contains?: boolean;
30
+ caseSensitive?: boolean;
31
+ limit?: number;
32
+ }
33
+ export interface LocalisationIndexEntry {
34
+ key: string;
35
+ value: string;
36
+ file: string;
37
+ line: number;
38
+ language: string;
39
+ }
40
+ export interface IndexQueryResult<TEntry> {
41
+ status: 'ready' | 'partial' | 'indexing' | 'idle' | 'unavailable' | 'error';
42
+ totalCount: number;
43
+ entries: TEntry[];
44
+ indexedSymbolNames?: number;
45
+ indexUpdatedAt?: number;
46
+ error?: string;
47
+ _hint?: string;
48
+ }
49
+ export interface IndexHost {
50
+ ensureReady?(): Promise<void>;
51
+ invalidate?(filePath: string): Promise<void>;
52
+ queryWorkspace(query: WorkspaceIndexQuery): Promise<IndexQueryResult<WorkspaceIndexEntry>>;
53
+ queryLocalisation(query: LocalisationIndexQuery): Promise<IndexQueryResult<LocalisationIndexEntry>>;
54
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export interface LspCommandOptions {
2
+ timeoutMs?: number;
3
+ }
4
+ export interface LspHost {
5
+ executeCommand<T = unknown>(command: string, args?: unknown[], options?: LspCommandOptions): Promise<T>;
6
+ request?<T = unknown>(method: string, params?: unknown, options?: LspCommandOptions): Promise<T>;
7
+ }
8
+ export declare function createUnavailableLspHost(message?: string): LspHost;
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createUnavailableLspHost = createUnavailableLspHost;
4
+ function createUnavailableLspHost(message = 'CWTools LSP is not connected.') {
5
+ return {
6
+ async executeCommand() {
7
+ return {
8
+ ok: false,
9
+ status: 'unavailable',
10
+ error: {
11
+ code: 'lsp_unavailable',
12
+ message,
13
+ },
14
+ };
15
+ },
16
+ async request() {
17
+ return {
18
+ ok: false,
19
+ status: 'unavailable',
20
+ error: {
21
+ code: 'lsp_unavailable',
22
+ message,
23
+ },
24
+ };
25
+ },
26
+ };
27
+ }
@@ -0,0 +1,11 @@
1
+ import type { SharedToolResult } from '../tools/schema';
2
+ export interface LspReadiness {
3
+ ready: boolean;
4
+ phase?: string;
5
+ inProgress?: boolean;
6
+ reason?: string;
7
+ }
8
+ export declare const LOAD_DEPENDENT_TOOLS: ReadonlySet<string>;
9
+ export declare const READINESS_LOADING_WARNING = "CWTools is still loading the project (parsing vanilla + building types/rules); this result is not yet authoritative. Retry after loading completes.";
10
+ export declare function parseReadiness(validationStatus: unknown): LspReadiness;
11
+ export declare function annotateReadiness(toolName: string, result: SharedToolResult, readiness: LspReadiness | undefined): SharedToolResult;
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.READINESS_LOADING_WARNING = exports.LOAD_DEPENDENT_TOOLS = void 0;
4
+ exports.parseReadiness = parseReadiness;
5
+ exports.annotateReadiness = annotateReadiness;
6
+ // Semantic tools that need the game fully loaded to return trustworthy results.
7
+ // get_pdx_block is excluded: it is plain in-workspace text extraction.
8
+ exports.LOAD_DEPENDENT_TOOLS = new Set([
9
+ 'query_types',
10
+ 'query_rules',
11
+ 'query_cwt_schema',
12
+ 'search_rule_capabilities',
13
+ 'explain_scope',
14
+ 'parse_pdx_fragment',
15
+ 'query_scope',
16
+ 'get_completion_at',
17
+ 'query_definition',
18
+ 'query_definition_by_name',
19
+ 'explore_pdx_project',
20
+ 'query_references',
21
+ 'get_diagnostics',
22
+ 'query_scripted_effects',
23
+ 'query_scripted_triggers',
24
+ 'query_enums',
25
+ 'query_static_modifiers',
26
+ 'query_variables',
27
+ 'get_entity_info',
28
+ ]);
29
+ exports.READINESS_LOADING_WARNING = 'CWTools is still loading the project (parsing vanilla + building types/rules); this result is not yet authoritative. Retry after loading completes.';
30
+ // Parse cwtools.ai.getValidationStatus into a readiness verdict. Pure; no IO.
31
+ function parseReadiness(validationStatus) {
32
+ const rec = validationStatus && typeof validationStatus === 'object'
33
+ ? validationStatus
34
+ : {};
35
+ if (rec.ok === false || rec.status === 'unavailable') {
36
+ return { ready: false, reason: 'lsp_unavailable' };
37
+ }
38
+ const loading = rec.loading && typeof rec.loading === 'object'
39
+ ? rec.loading
40
+ : {};
41
+ const inProgress = loading.inProgress === true;
42
+ const phase = typeof loading.phase === 'string' ? loading.phase : undefined;
43
+ const everLoaded = phase !== undefined && phase !== 'not_started';
44
+ const ready = !inProgress && everLoaded;
45
+ return {
46
+ ready,
47
+ phase,
48
+ inProgress,
49
+ reason: ready ? undefined : inProgress ? `loading:${phase ?? 'unknown'}` : 'not_started',
50
+ };
51
+ }
52
+ // Mark a load-dependent result as `loading` (not a trustworthy empty answer) when
53
+ // the game is not ready yet, so clients retry instead of trusting the result. Pure.
54
+ function annotateReadiness(toolName, result, readiness) {
55
+ if (!readiness || !exports.LOAD_DEPENDENT_TOOLS.has(toolName))
56
+ return result;
57
+ if (readiness.ready) {
58
+ return { ...result, readiness };
59
+ }
60
+ return {
61
+ ...result,
62
+ ok: true,
63
+ status: 'loading',
64
+ readiness,
65
+ warnings: [...(result.warnings ?? []), exports.READINESS_LOADING_WARNING],
66
+ nextSteps: [
67
+ ...(result.nextSteps ?? []),
68
+ 'Retry after the project finishes loading (poll get_diagnostics until freshness is fresh).',
69
+ ],
70
+ };
71
+ }
@@ -0,0 +1,12 @@
1
+ import type { SharedToolResult } from '../tools/schema';
2
+ export interface VanillaCacheStatus {
3
+ available: boolean;
4
+ source: 'mod_plus_vanilla' | 'mod_only';
5
+ cacheFile?: string;
6
+ gamePath?: string;
7
+ reason?: string;
8
+ }
9
+ export declare function vanillaCacheFileName(game: string | undefined): string | undefined;
10
+ export declare const VANILLA_DEPENDENT_TOOLS: ReadonlySet<string>;
11
+ export declare const VANILLA_UNAVAILABLE_WARNING = "Vanilla game cache is not loaded; results reflect mod files only. Vanilla IDs will not appear and mod references to vanilla definitions may be reported as undefined. Pass --cache <dir> (a built .cwb cache dir) or --game-path <dir> (a vanilla install to build from).";
12
+ export declare function annotateVanillaCache(toolName: string, result: SharedToolResult, status: VanillaCacheStatus | undefined): SharedToolResult;
@@ -0,0 +1,56 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.VANILLA_UNAVAILABLE_WARNING = exports.VANILLA_DEPENDENT_TOOLS = void 0;
4
+ exports.vanillaCacheFileName = vanillaCacheFileName;
5
+ exports.annotateVanillaCache = annotateVanillaCache;
6
+ // Game id -> `.cwb` prefix, mirroring GameLoader.fs getCachedFiles / Program.fs
7
+ // checkOrSetGameCache. Keep in sync with the F# side.
8
+ const GAME_CACHE_PREFIX = {
9
+ stellaris: 'stl',
10
+ hoi4: 'hoi4',
11
+ eu4: 'eu4',
12
+ eu5: 'eu5',
13
+ ck2: 'ck2',
14
+ ck3: 'ck3',
15
+ imperator: 'ir',
16
+ vic2: 'vic2',
17
+ vic3: 'vic3',
18
+ };
19
+ function vanillaCacheFileName(game) {
20
+ const prefix = GAME_CACHE_PREFIX[(game ?? 'stellaris').toLowerCase()];
21
+ return prefix ? `${prefix}.cwb` : undefined;
22
+ }
23
+ // Read-only tools whose results are only complete when vanilla data is loaded.
24
+ // query_rules is excluded: it resolves from bundled CWT rules, not vanilla data.
25
+ exports.VANILLA_DEPENDENT_TOOLS = new Set([
26
+ 'query_types',
27
+ 'get_completion_at',
28
+ 'query_scope',
29
+ 'query_definition',
30
+ 'query_definition_by_name',
31
+ 'explore_pdx_project',
32
+ 'query_project_knowledge',
33
+ 'query_references',
34
+ 'get_diagnostics',
35
+ 'query_scripted_effects',
36
+ 'query_scripted_triggers',
37
+ 'query_enums',
38
+ 'query_static_modifiers',
39
+ 'query_variables',
40
+ 'get_entity_info',
41
+ ]);
42
+ exports.VANILLA_UNAVAILABLE_WARNING = 'Vanilla game cache is not loaded; results reflect mod files only. Vanilla IDs will not appear and mod references to vanilla definitions may be reported as undefined. Pass --cache <dir> (a built .cwb cache dir) or --game-path <dir> (a vanilla install to build from).';
43
+ // Attach vanilla-cache provenance to a vanilla-dependent tool result so external
44
+ // agents never mistake a mod-only answer for a complete one. Pure; no IO.
45
+ function annotateVanillaCache(toolName, result, status) {
46
+ if (!status || !exports.VANILLA_DEPENDENT_TOOLS.has(toolName))
47
+ return result;
48
+ const annotated = {
49
+ ...result,
50
+ vanillaCache: status,
51
+ };
52
+ if (!status.available) {
53
+ annotated.warnings = [...(result.warnings ?? []), exports.VANILLA_UNAVAILABLE_WARNING];
54
+ }
55
+ return annotated;
56
+ }
@@ -0,0 +1,27 @@
1
+ import type { HostServices } from './hostServices';
2
+ export interface VsCodeHostServicesPorts {
3
+ workspaceRoot: string;
4
+ readonlyMode: boolean;
5
+ writesEnabled: boolean;
6
+ executeLspCommand<T = unknown>(command: string, args?: unknown[], timeoutMs?: number): Promise<T>;
7
+ getDiagnostics(args?: unknown): Promise<unknown>;
8
+ readTextFile(path: string): Promise<{
9
+ content: string;
10
+ hasBom: boolean;
11
+ exists: boolean;
12
+ }>;
13
+ writeTextFile(path: string, content: string): Promise<void>;
14
+ list(path: string): Promise<Array<{
15
+ name: string;
16
+ type: 'file' | 'directory';
17
+ size?: number;
18
+ }>>;
19
+ glob(pattern: string, options?: {
20
+ limit?: number;
21
+ }): Promise<string[]>;
22
+ queryWorkspaceIndex?(args: unknown): Promise<unknown>;
23
+ queryLocalisationIndex?(args: unknown): Promise<unknown>;
24
+ now?(): number;
25
+ log?(level: 'debug' | 'info' | 'warn' | 'error', message: string, data?: unknown): void;
26
+ }
27
+ export declare function createVsCodeHostServicesSkeleton(ports: VsCodeHostServicesPorts): HostServices;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createVsCodeHostServicesSkeleton = createVsCodeHostServicesSkeleton;
4
+ function createVsCodeHostServicesSkeleton(ports) {
5
+ return {
6
+ workspaceRoot: ports.workspaceRoot,
7
+ readonlyMode: ports.readonlyMode,
8
+ writesEnabled: ports.writesEnabled,
9
+ lsp: {
10
+ executeCommand: (command, args, options) => ports.executeLspCommand(command, args, options?.timeoutMs),
11
+ },
12
+ diagnostics: {
13
+ getDiagnostics: async (args) => ports.getDiagnostics(args),
14
+ },
15
+ filesystem: {
16
+ readTextFile: path => ports.readTextFile(path),
17
+ writeTextFile: (path, content) => ports.writeTextFile(path, content),
18
+ list: path => ports.list(path),
19
+ glob: (pattern, options) => ports.glob(pattern, options),
20
+ },
21
+ indexing: ports.queryWorkspaceIndex && ports.queryLocalisationIndex
22
+ ? {
23
+ queryWorkspace: async (query) => ports.queryWorkspaceIndex(query),
24
+ queryLocalisation: async (query) => ports.queryLocalisationIndex(query),
25
+ }
26
+ : undefined,
27
+ now: ports.now ?? (() => Date.now()),
28
+ log: ports.log ?? (() => undefined),
29
+ };
30
+ }
@@ -0,0 +1,25 @@
1
+ export * from './generated/mcpTools';
2
+ export * from './host/diagnostics';
3
+ export * from './host/filesystem';
4
+ export * from './host/hostServices';
5
+ export * from './host/indexing';
6
+ export * from './host/lsp';
7
+ export * from './host/readiness';
8
+ export * from './host/vanillaCache';
9
+ export * from './host/vsCodeHostServices';
10
+ export * from './knowledge/diagnosticRouting';
11
+ export * from './knowledge/gameKnowledge';
12
+ export * from './knowledge/rules';
13
+ export * from './knowledge/workflowHints';
14
+ export * from './project/profile';
15
+ export * from './project/knowledge';
16
+ export * from './safety/localisation';
17
+ export * from './safety/paths';
18
+ export * from './safety/writes';
19
+ export * from './tools/mcpSchema';
20
+ export * from './tools/names';
21
+ export * from './tools/pdxBlock';
22
+ export * from './tools/registry';
23
+ export * from './tools/schema';
24
+ export * from './tools/symbols';
25
+ export * from './tools/toolHandlers';
package/dist/index.js ADDED
@@ -0,0 +1,41 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./generated/mcpTools"), exports);
18
+ __exportStar(require("./host/diagnostics"), exports);
19
+ __exportStar(require("./host/filesystem"), exports);
20
+ __exportStar(require("./host/hostServices"), exports);
21
+ __exportStar(require("./host/indexing"), exports);
22
+ __exportStar(require("./host/lsp"), exports);
23
+ __exportStar(require("./host/readiness"), exports);
24
+ __exportStar(require("./host/vanillaCache"), exports);
25
+ __exportStar(require("./host/vsCodeHostServices"), exports);
26
+ __exportStar(require("./knowledge/diagnosticRouting"), exports);
27
+ __exportStar(require("./knowledge/gameKnowledge"), exports);
28
+ __exportStar(require("./knowledge/rules"), exports);
29
+ __exportStar(require("./knowledge/workflowHints"), exports);
30
+ __exportStar(require("./project/profile"), exports);
31
+ __exportStar(require("./project/knowledge"), exports);
32
+ __exportStar(require("./safety/localisation"), exports);
33
+ __exportStar(require("./safety/paths"), exports);
34
+ __exportStar(require("./safety/writes"), exports);
35
+ __exportStar(require("./tools/mcpSchema"), exports);
36
+ __exportStar(require("./tools/names"), exports);
37
+ __exportStar(require("./tools/pdxBlock"), exports);
38
+ __exportStar(require("./tools/registry"), exports);
39
+ __exportStar(require("./tools/schema"), exports);
40
+ __exportStar(require("./tools/symbols"), exports);
41
+ __exportStar(require("./tools/toolHandlers"), exports);
@@ -0,0 +1,13 @@
1
+ export interface DiagnosticKnowledgeQuery {
2
+ code?: string;
3
+ message?: string;
4
+ }
5
+ export interface DiagnosticKnowledgeResult {
6
+ status: 'ready';
7
+ code?: string;
8
+ category: string;
9
+ explanation: string;
10
+ suggestedTools: string[];
11
+ nextSteps: string[];
12
+ }
13
+ export declare function analyzeDiagnosticKnowledge(query: DiagnosticKnowledgeQuery): DiagnosticKnowledgeResult;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.analyzeDiagnosticKnowledge = analyzeDiagnosticKnowledge;
4
+ function analyzeDiagnosticKnowledge(query) {
5
+ const code = query.code?.trim();
6
+ const message = query.message?.toLowerCase() ?? '';
7
+ if (code?.startsWith('CW001') || message.includes('syntax')) {
8
+ return {
9
+ status: 'ready',
10
+ code,
11
+ category: 'syntax',
12
+ explanation: 'The diagnostic appears to be a parse or syntax error.',
13
+ suggestedTools: ['get_pdx_block', 'document_symbols', 'query_cwt_schema', 'query_rules'],
14
+ nextSteps: [
15
+ 'Inspect the nearest complete block before editing.',
16
+ 'Verify brace balance and rule syntax before writing.',
17
+ ],
18
+ };
19
+ }
20
+ if (message.includes('localisation') || message.includes('localization')) {
21
+ return {
22
+ status: 'ready',
23
+ code,
24
+ category: 'localisation',
25
+ explanation: 'The diagnostic appears related to localisation keys or YML files.',
26
+ suggestedTools: ['query_localisation_index', 'write_localisation', 'get_diagnostics'],
27
+ nextSteps: [
28
+ 'Check whether the key already exists in the localisation index.',
29
+ 'Use write_localisation for any YML mutation.',
30
+ ],
31
+ };
32
+ }
33
+ if (message.includes('scope')) {
34
+ return {
35
+ status: 'ready',
36
+ code,
37
+ category: 'scope',
38
+ explanation: 'The diagnostic appears related to an invalid or unexpected scope.',
39
+ suggestedTools: ['query_scope', 'query_cwt_schema', 'query_rules', 'get_completion_at'],
40
+ nextSteps: [
41
+ 'Query the scope at the failing position.',
42
+ 'Verify valid scope changes or trigger/effect syntax before editing.',
43
+ ],
44
+ };
45
+ }
46
+ return {
47
+ status: 'ready',
48
+ code,
49
+ category: 'general',
50
+ explanation: 'No specialized diagnostic route matched; use LSP and indexed evidence before editing.',
51
+ suggestedTools: ['get_diagnostics', 'explore_pdx_project', 'query_cwt_schema', 'query_definition_by_name', 'query_workspace_index'],
52
+ nextSteps: [
53
+ 'Group similar diagnostics and inspect a representative block.',
54
+ 'Verify identifiers through indexed tools before making changes.',
55
+ ],
56
+ };
57
+ }
@@ -0,0 +1,20 @@
1
+ export interface GameKnowledgeCard {
2
+ id: string;
3
+ title: string;
4
+ facts: string[];
5
+ }
6
+ export interface GameKnowledgeResult {
7
+ status: 'ready' | 'partial';
8
+ source: 'stable-policy' | 'lsp-semantic-catalog';
9
+ game: string;
10
+ rulesGeneration?: number;
11
+ rulesContentHash?: string;
12
+ ruleCount?: number;
13
+ definitionTypeCount?: number;
14
+ cards: GameKnowledgeCard[];
15
+ }
16
+ /**
17
+ * Return stable routing policy plus current catalog metadata when supplied.
18
+ * Mutable game rules are deliberately not embedded in this package.
19
+ */
20
+ export declare function queryGameKnowledge(game?: string, semanticCatalog?: unknown): GameKnowledgeResult;
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.queryGameKnowledge = queryGameKnowledge;
4
+ function asRecord(value) {
5
+ return value && typeof value === 'object' && !Array.isArray(value)
6
+ ? value
7
+ : undefined;
8
+ }
9
+ /**
10
+ * Return stable routing policy plus current catalog metadata when supplied.
11
+ * Mutable game rules are deliberately not embedded in this package.
12
+ */
13
+ function queryGameKnowledge(game = 'paradox', semanticCatalog) {
14
+ const catalog = asRecord(semanticCatalog);
15
+ const rules = Array.isArray(catalog?.rules) ? catalog.rules : [];
16
+ const definitionTypes = Array.isArray(catalog?.definitionTypes) ? catalog.definitionTypes : [];
17
+ const hasCatalog = rules.length > 0 || definitionTypes.length > 0;
18
+ const resolvedGame = typeof catalog?.gameProfile === 'string' && catalog.gameProfile.trim()
19
+ ? catalog.gameProfile.toLowerCase()
20
+ : game.toLowerCase();
21
+ const cards = [
22
+ {
23
+ id: 'dynamic-evidence-routing',
24
+ title: 'Dynamic game evidence',
25
+ facts: [
26
+ 'Obtain definition paths and identifier shapes from the active CWTools TypeDefs.',
27
+ 'Obtain rule arguments, typed references, and scope constraints from active CWT/LSP queries.',
28
+ 'Treat project and vanilla indexes as examples and dependency evidence; validate legality through current rules and diagnostics.',
29
+ ],
30
+ },
31
+ ];
32
+ if (hasCatalog) {
33
+ cards.push({
34
+ id: 'active-semantic-catalog',
35
+ title: 'Active semantic catalog',
36
+ facts: [
37
+ `${rules.length} rule aliases and ${definitionTypes.length} definition types are currently available.`,
38
+ 'Use focused query_rules, query_types, query_cwt_schema, and query_scope calls to retrieve the exact facts needed for the current task.',
39
+ ],
40
+ });
41
+ }
42
+ return {
43
+ status: hasCatalog ? 'ready' : 'partial',
44
+ source: hasCatalog ? 'lsp-semantic-catalog' : 'stable-policy',
45
+ game: resolvedGame,
46
+ rulesGeneration: typeof catalog?.rulesGeneration === 'number' ? catalog.rulesGeneration : undefined,
47
+ rulesContentHash: typeof catalog?.rulesContentHash === 'string' ? catalog.rulesContentHash : undefined,
48
+ ruleCount: rules.length,
49
+ definitionTypeCount: definitionTypes.length,
50
+ cards,
51
+ };
52
+ }