dsh-cwtools 0.0.0-stage → 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.
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Copy for the CWTools settings section.
3
+ *
4
+ * Section, group, field, and form-frame text lives here. Tool names, field
5
+ * paths, and configuration keys stay verbatim from the frozen contract and are
6
+ * never translated.
7
+ */
8
+ /** Every key this section renders. */
9
+ export type CwtoolsLocaleKey = 'nav' | 'title' | 'intro' | 'sectionBackend' | 'sectionReadAccess' | 'sectionWriteAccess' | 'sectionOutput' | 'enabled' | 'enabledHint' | 'serverPath' | 'serverPathHint' | 'gamePath' | 'gamePathHint' | 'rulesPath' | 'rulesPathHint' | 'cachePath' | 'cachePathHint' | 'activeManifestPath' | 'activeManifestPathHint' | 'preferActiveBackend' | 'preferActiveBackendHint' | 'game' | 'gameHint' | 'forceStart' | 'forceStartHint' | 'debug' | 'debugHint' | 'startupTimeoutMs' | 'startupTimeoutMsHint' | 'requestTimeoutMs' | 'requestTimeoutMsHint' | 'idleShutdownMs' | 'idleShutdownMsHint' | 'maxWorkspaceRuntimes' | 'maxWorkspaceRuntimesHint' | 'maxResultChars' | 'maxResultCharsHint' | 'writeLocalisation' | 'writeLocalisationHint' | 'writePolicyNote' | 'groupProject' | 'groupLocalisation' | 'groupSemantic' | 'groupNavigation' | 'groupDiagnostics' | 'groupShader' | 'groupDisabledNote' | 'readAccessIntro' | 'overridden' | 'reset' | 'invalidNumber' | 'readOnly' | 'unavailable' | 'save' | 'saving' | 'saveFailed' | 'failedTitle' | 'acceptedValue' | 'retryHint' | 'conflictNotice' | 'emptyValue' | 'on' | 'off';
10
+ /** English copy. */
11
+ export declare const en: Record<CwtoolsLocaleKey, string>;
12
+ /** Simplified Chinese copy, checked against the English keys. */
13
+ export declare const zh: Record<CwtoolsLocaleKey, string>;
14
+ /**
15
+ * The shared settings frame's copy, read from this section's dictionary.
16
+ * @param t - the section's locale reader.
17
+ * @returns the labels the shared form frame renders.
18
+ */
19
+ export declare function formLabels(t: (key: CwtoolsLocaleKey) => string): {
20
+ unavailable: string;
21
+ readOnly: string;
22
+ saveFailed: string;
23
+ save: string;
24
+ saving: string;
25
+ };
@@ -0,0 +1,7 @@
1
+ import z from '@deepseek-ai/schemastery';
2
+ import type { CwtoolsConfig, CwtoolsConfigInput } from './contract/configTypes.ts';
3
+ import { type CwtoolsReadToolName } from './contract/toolCatalog.ts';
4
+ export type Config = CwtoolsConfig;
5
+ export declare const Config: z<CwtoolsConfigInput, Config>;
6
+ export declare function isReadToolEnabled(config: Config, name: CwtoolsReadToolName): boolean;
7
+ export declare function isWriteLocalisationEnabled(config: Config): boolean;
@@ -0,0 +1,37 @@
1
+ import type { CwtoolsReadGroup, CwtoolsReadToolName, CwtoolsWriteToolName } from './toolCatalog.ts';
2
+ export interface CwtoolsBackendConfig {
3
+ serverPath: string;
4
+ gamePath: string;
5
+ rulesPath: string;
6
+ cachePath: string;
7
+ game: string;
8
+ forceStart: boolean;
9
+ startupTimeoutMs: number;
10
+ requestTimeoutMs: number;
11
+ idleShutdownMs: number;
12
+ maxWorkspaceRuntimes: number;
13
+ preferActiveBackend: boolean;
14
+ activeManifestPath: string;
15
+ debug: boolean;
16
+ }
17
+ export interface CwtoolsConfig {
18
+ enabled: boolean;
19
+ readGroups: Record<CwtoolsReadGroup, boolean>;
20
+ readTools: Partial<Record<CwtoolsReadToolName, boolean>>;
21
+ writeTools: Partial<Record<CwtoolsWriteToolName, boolean>>;
22
+ backend: CwtoolsBackendConfig;
23
+ output: {
24
+ maxResultChars: number;
25
+ };
26
+ }
27
+ /** User/config-layer input before Schemastery fills defaults. */
28
+ export interface CwtoolsConfigInput {
29
+ enabled?: boolean;
30
+ readGroups?: Partial<Record<CwtoolsReadGroup, boolean>>;
31
+ readTools?: Partial<Record<CwtoolsReadToolName, boolean>>;
32
+ writeTools?: Partial<Record<CwtoolsWriteToolName, boolean>>;
33
+ backend?: Partial<CwtoolsBackendConfig>;
34
+ output?: {
35
+ maxResultChars?: number;
36
+ };
37
+ }
@@ -0,0 +1,19 @@
1
+ export declare const CWTOOLS_READ_TOOL_GROUPS: {
2
+ readonly project: readonly ["query_project_profile", "query_project_knowledge", "query_workspace_index", "explore_pdx_project", "analyze_pdx_flow", "query_inline_instantiation", "compare_definition_with_vanilla"];
3
+ readonly localisation: readonly ["query_localisation_index"];
4
+ readonly semantic: readonly ["query_types", "query_rules", "query_cwt_schema", "search_rule_capabilities", "explain_scope", "parse_pdx_fragment", "query_scope", "query_scripted_effects", "query_scripted_triggers", "query_enums", "query_static_modifiers", "query_variables", "get_entity_info", "get_pdx_block", "query_targeting_weight"];
5
+ readonly navigation: readonly ["get_completion_at", "document_symbols", "workspace_symbols", "go_to_definition", "find_references"];
6
+ readonly diagnostics: readonly ["get_diagnostics", "analyze_diagnostic_error"];
7
+ readonly shader: readonly ["query_shader_symbol", "query_shader_compile_unit", "query_shader_platform_variants", "query_shader_callers", "explain_shader_reachability", "validate_shader", "compare_shader_with_vanilla"];
8
+ };
9
+ export type CwtoolsReadGroup = keyof typeof CWTOOLS_READ_TOOL_GROUPS;
10
+ export type CwtoolsReadToolName = typeof CWTOOLS_READ_TOOL_GROUPS[CwtoolsReadGroup][number];
11
+ export declare const CWTOOLS_READ_GROUP_ORDER: readonly CwtoolsReadGroup[];
12
+ export declare const CWTOOLS_READ_TOOL_NAMES: readonly CwtoolsReadToolName[];
13
+ export declare const CWTOOLS_WRITE_TOOL_NAMES: readonly ["write_localisation"];
14
+ export type CwtoolsWriteToolName = typeof CWTOOLS_WRITE_TOOL_NAMES[number];
15
+ export declare const CWTOOLS_FIRST_RELEASE_TOOL_NAMES: readonly string[];
16
+ export declare const CWTOOLS_STELLARIS_ONLY_TOOLS: ReadonlySet<string>;
17
+ export declare function isCwtoolsReadToolName(name: string): name is CwtoolsReadToolName;
18
+ export declare function isCwtoolsWriteToolName(name: string): name is CwtoolsWriteToolName;
19
+ export declare function cwtoolsReadGroupFor(name: CwtoolsReadToolName): CwtoolsReadGroup;
@@ -0,0 +1,8 @@
1
+ import { type LspHost } from 'cwtools-node';
2
+ import type { Config } from '../config.ts';
3
+ export interface ActiveBackend {
4
+ lspHost: LspHost;
5
+ readyAtMs?: number;
6
+ }
7
+ /** Resolve a healthy active host only for the exact current mod root. */
8
+ export declare function resolveActiveBackend(config: Config, workspaceRoot: string, signal: AbortSignal): Promise<ActiveBackend | undefined>;
@@ -0,0 +1,22 @@
1
+ import type { HostServices, SharedToolResult } from 'cwtools-shared';
2
+ export interface CwtoolsExecutionContext {
3
+ signal?: AbortSignal;
4
+ }
5
+ export type CwtoolsToolCallHandler = (name: string, args?: Record<string, unknown>, context?: CwtoolsExecutionContext) => Promise<SharedToolResult>;
6
+ export interface CwtoolsNodeHostOptions {
7
+ workspaceRoot: string;
8
+ game?: string;
9
+ serverPath?: string;
10
+ gamePath?: string;
11
+ cachePath?: string;
12
+ rulesPath?: string;
13
+ enableWrites: boolean;
14
+ allowedTools: string[];
15
+ forceStart: boolean;
16
+ startupTimeoutMs?: number;
17
+ requestTimeoutMs?: number;
18
+ lspHost?: HostServices['lsp'];
19
+ readyAtMs?: number;
20
+ debug?: boolean;
21
+ }
22
+ export type CwtoolsNodeHostFactory = (options: CwtoolsNodeHostOptions) => HostServices;
@@ -0,0 +1,9 @@
1
+ export declare class CwtoolsToolError extends Error {
2
+ readonly code: string;
3
+ readonly nextSteps: readonly string[];
4
+ readonly name = "CwtoolsToolError";
5
+ constructor(code: string, message: string, nextSteps?: readonly string[]);
6
+ }
7
+ export declare function abortError(reason?: unknown): Error;
8
+ export declare function throwIfAborted(signal: AbortSignal | undefined): void;
9
+ export declare function awaitWithAbort<T>(promise: Promise<T>, signal: AbortSignal | undefined): Promise<T>;
@@ -0,0 +1,4 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Config } from '../config.ts';
3
+ import type { CwtoolsRuntimePool } from './runtime.ts';
4
+ export declare function registerNativeCwtoolsTools(ctx: Context, config: Config, runtime: CwtoolsRuntimePool): () => void;
@@ -0,0 +1 @@
1
+ export declare const CWTOOLS_SYSTEM_PROMPT = "CWTools provides native semantic and explicitly allowed domain-write tools for Paradox mods. Ground claims about the mod in these tools rather than memory: PDX identifiers and syntax are easy to hallucinate.\n\nWhen working in a Paradox mod:\n- Start structural and dependency questions with explore_pdx_project.\n- Verify game IDs with query_types and the appropriate scripted effect/trigger, enum, modifier, or variable query before using them.\n- Check trigger/effect/scope/modifier syntax with query_rules and query_scope; check block and entity schemas with query_cwt_schema before writing.\n- Navigate with go_to_definition/find_references/document_symbols/workspace_symbols and use get_pdx_block for structured blocks.\n- Respect readiness and freshness. A loading result or an empty result while readiness.ready is false is not authoritative; retry after loading.\n- Respect vanillaCache provenance. When vanilla is unavailable, results are mod-only and vanilla references may produce incomplete answers or false errors.\n- Review get_diagnostics before declaring code correct. After an allowed write, re-check fresh diagnostics.\n- Only whitelisted domain writes may be used, and only when enabled by the user. Never treat a denied write as completed.";
@@ -0,0 +1,7 @@
1
+ import type { ToolDefinition } from '@deepseek-ai/dsh-tools';
2
+ import type { SharedToolResult } from 'cwtools-shared';
3
+ import { CwtoolsToolError } from './errors.ts';
4
+ export declare function normalizeSuccessfulResult(result: SharedToolResult): SharedToolResult;
5
+ export declare function errorFromSharedResult(result: SharedToolResult): CwtoolsToolError;
6
+ export declare function renderCwtoolsResult(value: unknown, maxResultChars: number): string;
7
+ export declare const SUCCESS_OUTPUT_SCHEMA: ToolDefinition['output']['schema'];
@@ -0,0 +1,22 @@
1
+ import { type SharedToolResult } from 'cwtools-shared';
2
+ import type { Config } from '../config.ts';
3
+ export declare class CwtoolsRuntimePool {
4
+ private readonly config;
5
+ private readonly entries;
6
+ private readonly pendingEntries;
7
+ private disposed;
8
+ constructor(config: Config);
9
+ get workspaceCount(): number;
10
+ canExpose(name: string, workspaceRoot: string): boolean;
11
+ exposureReason(name: string, workspaceRoot: string): string | undefined;
12
+ execute(name: string, args: Record<string, unknown>, workspaceRoot: string, signal: AbortSignal): Promise<SharedToolResult>;
13
+ dispose(): void;
14
+ private resolveProject;
15
+ private entryFor;
16
+ private createEntry;
17
+ private enforceCapacity;
18
+ private serial;
19
+ private clearIdle;
20
+ private scheduleIdle;
21
+ private disposeEntry;
22
+ }
@@ -0,0 +1,7 @@
1
+ import type { Context } from '@deepseek-ai/cordis';
2
+ import type { Config } from './config.ts';
3
+ export { Config } from './config.ts';
4
+ export declare const name = "cwtools";
5
+ export declare const inject: string[];
6
+ /** Register native CWTools tools and own every runtime resource in one effect. */
7
+ export declare function apply(ctx: Context, config: Config): void;
package/locale/en.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "CWTools",
4
+ "description": "Configure the CWTools language server, its read and write tool grants, and result output."
5
+ }
6
+ }
package/locale/zh.json ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "meta": {
3
+ "title": "CWTools",
4
+ "description": "配置 CWTools 语言服务器、只读与写入工具权限,以及结果输出。"
5
+ }
6
+ }
package/package.json CHANGED
@@ -1,6 +1,94 @@
1
1
  {
2
2
  "name": "dsh-cwtools",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "version": "0.1.0",
4
+ "description": "Native DeepSeek Harness tools and settings for CWTools Paradox modding",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "main": "lib/index.js",
8
+ "types": "lib/types/index.d.ts",
9
+ "exports": {
10
+ ".": {
11
+ "types": "./lib/types/index.d.ts",
12
+ "default": "./lib/index.js"
13
+ },
14
+ "./client": {
15
+ "types": "./lib/types/client/index.d.ts",
16
+ "default": "./lib/client.js"
17
+ },
18
+ "./locale/*.json": "./locale/*.json",
19
+ "./icon": "./icon.svg",
20
+ "./package.json": "./package.json"
21
+ },
22
+ "files": [
23
+ "lib/index.js",
24
+ "lib/client.js",
25
+ "lib/types/**/*.d.ts",
26
+ "cordis.patch.yml",
27
+ "locale/*.json",
28
+ "icon.svg",
29
+ "README.md",
30
+ "LICENSE"
31
+ ],
32
+ "dsh": {
33
+ "bundle": {
34
+ "patch": "./cordis.patch.yml"
35
+ },
36
+ "client": {
37
+ "platform": "web",
38
+ "inject": [
39
+ "@deepseek-ai/dsh-client-locale",
40
+ "@deepseek-ai/dsh-client-ui-settings",
41
+ "@deepseek-ai/dsh-client-ui-settings-general"
42
+ ]
43
+ }
44
+ },
45
+ "engines": {
46
+ "node": ">=24.9.0",
47
+ "dsh": ">=0.2.2-rc.1 <0.3.0"
48
+ },
49
+ "dependencies": {
50
+ "@deepseek-ai/schemastery": "^3.19.0",
51
+ "cwtools-node": "0.1.0",
52
+ "cwtools-shared": "0.3.0"
53
+ },
54
+ "peerDependencies": {
55
+ "@deepseek-ai/cordis": "^4.1.0",
56
+ "@deepseek-ai/dsh-system-prompt": ">=0.2.2-rc.1 <0.3.0",
57
+ "@deepseek-ai/dsh-tools": ">=0.2.2-rc.1 <0.3.0",
58
+ "@deepseek-ai/dsh-working-directory": ">=0.2.2-rc.1 <0.3.0"
59
+ },
60
+ "devDependencies": {
61
+ "@deepseek-ai/cordis": "^4.1.0",
62
+ "@deepseek-ai/dsh-api-remotes": ">=0.2.2-rc.1 <0.3.0",
63
+ "@deepseek-ai/dsh-client-locale": ">=0.2.2-rc.1 <0.3.0",
64
+ "@deepseek-ai/dsh-client-store": ">=0.2.2-rc.1 <0.3.0",
65
+ "@deepseek-ai/dsh-client-ui-primitives": ">=0.2.2-rc.1 <0.3.0",
66
+ "@deepseek-ai/dsh-client-ui-renderer": ">=0.2.2-rc.1 <0.3.0",
67
+ "@deepseek-ai/dsh-client-ui-settings": ">=0.2.2-rc.1 <0.3.0",
68
+ "@deepseek-ai/dsh-client-ui-settings-general": ">=0.2.2-rc.1 <0.3.0",
69
+ "@deepseek-ai/dsh-client-ui-slots": ">=0.2.2-rc.1 <0.3.0",
70
+ "@deepseek-ai/dsh-system-prompt": ">=0.2.2-rc.1 <0.3.0",
71
+ "@deepseek-ai/dsh-tools": ">=0.2.2-rc.1 <0.3.0",
72
+ "@deepseek-ai/dsh-working-directory": ">=0.2.2-rc.1 <0.3.0",
73
+ "@testing-library/react": "^16.3.0",
74
+ "@types/node": "^24.0.0",
75
+ "@types/react": "^18.3.0",
76
+ "@types/react-dom": "^18.3.0",
77
+ "jsdom": "^26.1.0",
78
+ "lightningcss": "^1.30.0",
79
+ "playwright-core": "^1.56.0",
80
+ "react": "^18.2.0",
81
+ "react-dom": "^18.2.0",
82
+ "tsdown": "^0.22.2",
83
+ "typescript": "^5.8.3",
84
+ "vitest": "^4.0.0"
85
+ },
86
+ "scripts": {
87
+ "build": "pnpm run typecheck && pnpm run build:types && tsdown",
88
+ "build:types": "tsc -p tsconfig.build.json",
89
+ "typecheck": "tsc -p tsconfig.json --noEmit",
90
+ "test": "vitest run",
91
+ "test:host": "vitest run tests/host",
92
+ "test:client": "vitest run tests/client"
93
+ }
6
94
  }