@crowdedkingdoms/crowdy-dsh 0.2.0-dev.1 → 0.2.0-dev.2

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 (105) hide show
  1. package/THIRD_PARTY_NOTICES.md +226 -0
  2. package/dist/dsh-web/BUILD.json +3 -3
  3. package/dist/dsh-web/preview/vfs-image.tar.gz +0 -0
  4. package/lib/attachments/crowdy-attachment-store.js +200 -0
  5. package/lib/attachments/crowdy-attachment-store.js.map +1 -0
  6. package/lib/bridge/client.js +161 -0
  7. package/lib/bridge/client.js.map +1 -0
  8. package/lib/bridge/index.js +155 -0
  9. package/lib/bridge/index.js.map +1 -0
  10. package/lib/bridge/protocol.js +30 -0
  11. package/lib/bridge/protocol.js.map +1 -0
  12. package/lib/crowdy/client.js +247 -0
  13. package/lib/crowdy/client.js.map +1 -0
  14. package/lib/crowdy/config.js +95 -0
  15. package/lib/crowdy/config.js.map +1 -0
  16. package/lib/crowdy/github-layout.js +97 -0
  17. package/lib/crowdy/github-layout.js.map +1 -0
  18. package/lib/crowdy/paths.js +145 -0
  19. package/lib/crowdy/paths.js.map +1 -0
  20. package/lib/crowdy/project-store.js +223 -0
  21. package/lib/crowdy/project-store.js.map +1 -0
  22. package/lib/fs/crowdy-file-system.js +621 -0
  23. package/lib/fs/crowdy-file-system.js.map +1 -0
  24. package/lib/fs/scratch-store.js +61 -0
  25. package/lib/fs/scratch-store.js.map +1 -0
  26. package/lib/index.js +15 -0
  27. package/lib/index.js.map +1 -0
  28. package/lib/persist/index.js +199 -0
  29. package/lib/persist/index.js.map +1 -0
  30. package/lib/scripts/probe.js +59 -0
  31. package/lib/scripts/probe.js.map +1 -0
  32. package/lib/sdk-index/catalog.js +237 -0
  33. package/lib/sdk-index/catalog.js.map +1 -0
  34. package/lib/sdk-index/index.js +10 -0
  35. package/lib/sdk-index/index.js.map +1 -0
  36. package/lib/sdk-index/parse-sdk.js +131 -0
  37. package/lib/sdk-index/parse-sdk.js.map +1 -0
  38. package/lib/sdk-index/plugin.js +90 -0
  39. package/lib/sdk-index/plugin.js.map +1 -0
  40. package/lib/sdk-index/snapshot.js +215 -0
  41. package/lib/sdk-index/snapshot.js.map +1 -0
  42. package/lib/search/glob-match.js +114 -0
  43. package/lib/search/glob-match.js.map +1 -0
  44. package/lib/search/search-tools.js +414 -0
  45. package/lib/search/search-tools.js.map +1 -0
  46. package/lib/tools/index.js +344 -0
  47. package/lib/tools/index.js.map +1 -0
  48. package/lib/types/attachments/crowdy-attachment-store.d.ts +45 -0
  49. package/lib/types/attachments/crowdy-attachment-store.d.ts.map +1 -0
  50. package/lib/types/attachments/crowdy-attachment-store.test.d.ts.map +1 -0
  51. package/lib/types/bridge/client.d.ts +57 -0
  52. package/lib/types/bridge/client.d.ts.map +1 -0
  53. package/lib/types/bridge/client.test.d.ts.map +1 -0
  54. package/lib/types/bridge/index.d.ts +66 -0
  55. package/lib/types/bridge/index.d.ts.map +1 -0
  56. package/lib/types/bridge/protocol.d.ts +242 -0
  57. package/lib/types/bridge/protocol.d.ts.map +1 -0
  58. package/lib/types/crowdy/client.d.ts +126 -0
  59. package/lib/types/crowdy/client.d.ts.map +1 -0
  60. package/lib/types/crowdy/client.test.d.ts.map +1 -0
  61. package/lib/types/crowdy/config.d.ts +60 -0
  62. package/lib/types/crowdy/config.d.ts.map +1 -0
  63. package/lib/types/crowdy/github-layout.d.ts +36 -0
  64. package/lib/types/crowdy/github-layout.d.ts.map +1 -0
  65. package/lib/types/crowdy/paths.d.ts +89 -0
  66. package/lib/types/crowdy/paths.d.ts.map +1 -0
  67. package/lib/types/crowdy/project-store.d.ts +84 -0
  68. package/lib/types/crowdy/project-store.d.ts.map +1 -0
  69. package/lib/types/crowdy/project-store.test.d.ts.map +1 -0
  70. package/lib/types/fs/crowdy-file-system.d.ts +173 -0
  71. package/lib/types/fs/crowdy-file-system.d.ts.map +1 -0
  72. package/lib/types/fs/crowdy-file-system.test.d.ts.map +1 -0
  73. package/lib/types/fs/scratch-store.d.ts +31 -0
  74. package/lib/types/fs/scratch-store.d.ts.map +1 -0
  75. package/lib/types/index.d.ts +19 -0
  76. package/lib/types/index.d.ts.map +1 -0
  77. package/lib/types/persist/index.d.ts +85 -0
  78. package/lib/types/persist/index.d.ts.map +1 -0
  79. package/lib/types/scripts/probe.d.ts +9 -0
  80. package/lib/types/scripts/probe.d.ts.map +1 -0
  81. package/lib/types/sdk-index/catalog.d.ts +39 -0
  82. package/lib/types/sdk-index/catalog.d.ts.map +1 -0
  83. package/lib/types/sdk-index/catalog.test.d.ts.map +1 -0
  84. package/lib/types/sdk-index/index.d.ts +13 -0
  85. package/lib/types/sdk-index/index.d.ts.map +1 -0
  86. package/lib/types/sdk-index/parse-sdk.d.ts +25 -0
  87. package/lib/types/sdk-index/parse-sdk.d.ts.map +1 -0
  88. package/lib/types/sdk-index/plugin.d.ts +26 -0
  89. package/lib/types/sdk-index/plugin.d.ts.map +1 -0
  90. package/lib/types/sdk-index/snapshot.d.ts +11 -0
  91. package/lib/types/sdk-index/snapshot.d.ts.map +1 -0
  92. package/lib/types/search/glob-match.d.ts +31 -0
  93. package/lib/types/search/glob-match.d.ts.map +1 -0
  94. package/lib/types/search/glob-match.test.d.ts.map +1 -0
  95. package/lib/types/search/search-tools.d.ts +81 -0
  96. package/lib/types/search/search-tools.d.ts.map +1 -0
  97. package/lib/types/search/search-tools.test.d.ts.map +1 -0
  98. package/lib/types/tools/index.d.ts +27 -0
  99. package/lib/types/tools/index.d.ts.map +1 -0
  100. package/lib/types/vendor/crowdyjs-sdk.d.ts +17 -0
  101. package/lib/types/vendor/crowdyjs-sdk.d.ts.map +1 -0
  102. package/lib/vendor/crowdyjs-sdk.js +18338 -0
  103. package/lib/vendor/crowdyjs-sdk.js.map +1 -0
  104. package/lib/vendor/crowdyjs-sdk.version.json +5 -0
  105. package/package.json +151 -38
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-store.d.ts","sourceRoot":"","sources":["../../../src/crowd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QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,IAAI;IAVvB,QAAQ,CAAC,IAAI,EAAG,QAAQ,CAAS;IACjC,OAAO,CAAC,IAAI,CAAqC;IACjD,OAAO,CAAC,MAAM,CAA0B;IACxC,+EAA+E;IAC/E,aAAa,EAAE,MAAM,GAAG,SAAS,CAAA;gBAGd,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,MAAM,EACjB,SAAS,EAAE,MAAM,EACjB,IAAI,GAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAsB;IAGpE,OAAO,KAAK,KAAK,GAEhB;IAEK,IAAI,IAAI,OAAO,CAAC,eAAe,CAAC;IAsDhC,MAAM,CAAC,QAAQ,EAAE,eAAe,EAAE,KAAK,EAAE,YAAY,GAAG,OAAO,CAAC,eAAe,CAAC;IAkDtF,2EAA2E;YAC7D,cAAc;CAe7B;AAaD,2EAA2E;AAC3E,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAElD;AAED,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,YAAY,CAAA;IACnB,0EAA0E;IAC1E,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;;GAGG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE,kBAAkB,EAC1B,SAAS,EAAE,MAAM,EACjB,OAAO,EAAE;IAAE,WAAW,EAAE,OAAO,CAAC;IAAC,IAAI,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAA;CAAE,GAClE,OAAO,CAAC,cAAc,CAAC,CAqBzB"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"project-store.test.d.ts","sourceRoot":"","sources":["../../../src/crowdy/project-store.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,173 @@
1
+ /**
2
+ * A DeepSeek Harness `ctx.fs` backend whose execution world is a Crowdy Studio
3
+ * project instead of a disk.
4
+ *
5
+ * The harness expects a filesystem; Crowdy Studio offers a small versioned bag
6
+ * of files behind a GraphQL API (or, for a GitHub-bound project, the bound
7
+ * repository). This class bridges the two:
8
+ *
9
+ * - identity — a target key is the virtual absolute path, which is stable
10
+ * because Crowdy paths never alias (no symlinks, no hardlinks).
11
+ * - freshness — `FsVersion` is a content hash, so a version changes exactly
12
+ * when the bytes change.
13
+ * - atomicity — every mutation is one store commit guarded by the revision it
14
+ * read, and a lost race surfaces as `FS_STALE_VERSION` rather
15
+ * than a silent overwrite.
16
+ *
17
+ * Beside the two project trees the mount carries in-memory scratch directories
18
+ * (`captures/`, `context/`) the Studio page fills over the bridge; see
19
+ * {@link ScratchStore}.
20
+ *
21
+ * @module @crowdedkingdoms/crowdy-dsh/fs
22
+ */
23
+ import type { Context } from '@deepseek-ai/cordis';
24
+ import z from '@deepseek-ai/schemastery';
25
+ import { FileSystem, FsVersion } from '@deepseek-ai/dsh-fs';
26
+ import type { FsDirEntry, FsEditOutcome, FsEditRequest, FsInfo, FsPathInfo, FsTarget, FsWriteIntent, FsWriteOutcome } from '@deepseek-ai/dsh-fs';
27
+ import { CrowdyStudioClient } from '../crowdy/client.js';
28
+ import type { CrowdyTarget } from '../crowdy/client.js';
29
+ import { type CrowdyBootConfig } from '../crowdy/config.js';
30
+ import { type ProjectSnapshot } from '../crowdy/project-store.js';
31
+ import { ScratchStore } from './scratch-store.js';
32
+ export type Config = Partial<CrowdyBootConfig> & {
33
+ /** How long a project snapshot may be reused for reads, in milliseconds. */
34
+ snapshotTtlMs?: number;
35
+ /** How often the GitHub/Studio store choice is re-evaluated, in milliseconds. */
36
+ storeTtlMs?: number;
37
+ };
38
+ /**
39
+ * Content-addressed freshness token. FNV-1a over UTF-16 code units: no
40
+ * `node:crypto` (absent in the browser worker), synchronous, and collisions
41
+ * only ever cost one spurious re-read of a small Rust file.
42
+ */
43
+ export declare function versionOf(content: string): FsVersion;
44
+ /**
45
+ * The model route resolves its bearer through `apiKeyEnv: CROWDY_APP_TOKEN`.
46
+ * The credentials provider reads the process environment on every request and
47
+ * the browser worker never sees a `.env` file (the launcher that reads those is
48
+ * absent there), so the token is published to `process.env` directly. In the
49
+ * cockpit the variable is already set by the operator and this is a no-op.
50
+ */
51
+ export declare const APP_TOKEN_ENV = "CROWDY_APP_TOKEN";
52
+ export declare class CrowdyFileSystem extends FileSystem {
53
+ static Config: z<Config>;
54
+ /** Effective boot configuration (file + environment + row config). */
55
+ boot: CrowdyBootConfig;
56
+ /** API client; replaceable in tests, mirroring the local backend's `internals` hook. */
57
+ client: CrowdyStudioClient;
58
+ /** In-memory scratch files the page and tools share. */
59
+ readonly scratch: ScratchStore;
60
+ private readonly root;
61
+ private readonly snapshotTtl;
62
+ private readonly storeTtl;
63
+ /** Cached project snapshot; reads may reuse it briefly, mutations never do. */
64
+ private snapshot;
65
+ private inflight;
66
+ private store;
67
+ private storeInflight;
68
+ /** Per-path tail promise serializing each read-guard-write critical section. */
69
+ private readonly locks;
70
+ /** Listeners told when the project files changed through this backend. */
71
+ private readonly changeListeners;
72
+ private readonly warnings;
73
+ private readonly warningListeners;
74
+ /** Resolved (and replaced) each time a bearer arrives over the bridge. */
75
+ private tokenWaiters;
76
+ constructor(ctx: Context, config?: Config);
77
+ /** Virtual root the project is mounted at. */
78
+ get mountRoot(): string;
79
+ /** Human-readable description of where files currently come from. */
80
+ get storeReason(): string | undefined;
81
+ /** Point the backend at another project (the page switched projects). */
82
+ setProject(projectId: string): void;
83
+ /** Replace the bearer after the page refreshed the app token. */
84
+ setToken(token: string | undefined): void;
85
+ /** Whether a bearer (or cockpit credentials) is available right now. */
86
+ get hasCredentials(): boolean;
87
+ /**
88
+ * In the browser the token follows the boot over the bridge rather than
89
+ * riding in `crowdy.json`, so the first project load may run a beat ahead of
90
+ * it. Wait briefly for it instead of failing the model's first tool call.
91
+ */
92
+ private waitForCredentials;
93
+ /** Subscribe to warnings (store fallbacks, failed mirrors) as they happen. */
94
+ onWarning(listener: (message: string) => void): () => void;
95
+ private warn;
96
+ /** Subscribe to writes made through this backend. */
97
+ onChange(listener: (change: {
98
+ target: CrowdyTarget;
99
+ path: string;
100
+ }) => void): () => void;
101
+ /** Drop any cached snapshot so the next read refetches (the page saved). */
102
+ invalidate(): void;
103
+ /** Warnings accumulated since the last drain (mirror failures, fallbacks). */
104
+ drainWarnings(): string[];
105
+ resolve(path: string, opts?: {
106
+ cwd?: string;
107
+ signal?: AbortSignal;
108
+ }): Promise<FsTarget>;
109
+ /**
110
+ * Pick the base for relative paths. A session's cwd comes from the host
111
+ * workspace and may point anywhere; resolving against a directory outside
112
+ * the mount would make every relative path a miss, so a foreign cwd falls
113
+ * back to the project root.
114
+ */
115
+ private baseFor;
116
+ processPath(target: FsTarget): string;
117
+ fileUrl(target: FsTarget): string;
118
+ contains(parent: FsTarget, child: FsTarget): boolean;
119
+ stat(target: FsTarget, signal?: AbortSignal): Promise<FsInfo | undefined>;
120
+ lstat(path: string, opts?: {
121
+ cwd?: string;
122
+ }, signal?: AbortSignal): Promise<FsPathInfo | undefined>;
123
+ readText(target: FsTarget, signal?: AbortSignal): Promise<string>;
124
+ streamText(target: FsTarget, signal?: AbortSignal): Promise<AsyncIterable<string>>;
125
+ readBytes(target: FsTarget, signal: AbortSignal | undefined, maxBytes: number): Promise<Uint8Array>;
126
+ readByteRange(target: FsTarget, range: {
127
+ offset: number;
128
+ length: number;
129
+ }, signal?: AbortSignal): Promise<Uint8Array>;
130
+ private bytesOf;
131
+ listDir(target: FsTarget, signal?: AbortSignal): Promise<FsDirEntry[]>;
132
+ writeText(target: FsTarget, content: string, expected?: FsWriteIntent, signal?: AbortSignal): Promise<FsWriteOutcome>;
133
+ editText(target: FsTarget, edit: FsEditRequest, expected?: {
134
+ version: FsVersion;
135
+ }, signal?: AbortSignal): Promise<FsEditOutcome>;
136
+ /**
137
+ * Apply a batch under the snapshot's revision, translating a lost optimistic
138
+ * race into the harness's stale-version vocabulary so the tool layer can tell
139
+ * the model to re-read rather than reporting an opaque server error.
140
+ */
141
+ private commit;
142
+ /**
143
+ * One coherent view of every project file for the search tools: the virtual
144
+ * mount root plus each file's virtual absolute path and content. Reuses the
145
+ * same snapshot as reads, so glob/grep and read describe the same tree.
146
+ */
147
+ searchSnapshot(): Promise<{
148
+ root: string;
149
+ files: Array<{
150
+ virtualPath: string;
151
+ content: string;
152
+ }>;
153
+ }>;
154
+ /** The current project snapshot, for tools that want the whole tree. */
155
+ currentProject(): Promise<ProjectSnapshot>;
156
+ /** Fetch the project, collapsing bursts and deduping concurrent fetches. */
157
+ private project;
158
+ /** Decide (and periodically re-decide) whether GitHub or Studio holds the files. */
159
+ private currentStore;
160
+ private find;
161
+ private requireFile;
162
+ /**
163
+ * Reject a write that Crowdy Studio would refuse anyway, so the model gets a
164
+ * precise reason instead of a generic server validation failure.
165
+ */
166
+ private requireWritableLocation;
167
+ private absolute;
168
+ private assertLive;
169
+ /** Serialize mutations per path so a read-guard-write window cannot interleave. */
170
+ private withLock;
171
+ }
172
+ export default CrowdyFileSystem;
173
+ //# sourceMappingURL=crowdy-file-system.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crowdy-file-system.d.ts","sourceRoot":"","sources":["../../../src/fs/crowdy-file-system.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AACxC,OAAO,EAAE,UAAU,EAAwB,SAAS,EAAE,MAAM,qBAAqB,CAAA;AACjF,OAAO,KAAK,EACV,UAAU,EACV,aAAa,EACb,aAAa,EACb,MAAM,EACN,UAAU,EACV,QAAQ,EACR,aAAa,EACb,cAAc,EACf,MAAM,qBAAqB,CAAA;AAE5B,OAAO,EAAkB,kBAAkB,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAAqB,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAC1E,OAAO,EAAqC,KA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AIG;YACW,MAAM;IAuCpB;;;;OAIG;IACG,cAAc,IAAI,OAAO,CAAC;QAC9B,IAAI,EAAE,MAAM,CAAA;QACZ,KAAK,EAAE,KAAK,CAAC;YAAE,WAAW,EAAE,MAAM,CAAC;YAAC,OAAO,EAAE,MAAM,CAAA;SAAE,CAAC,CAAA;KACvD,CAAC;IAgBF,wEAAwE;IAClE,cAAc,IAAI,OAAO,CAAC,eAAe,CAAC;IAIhD,4EAA4E;YAC9D,OAAO;IAuCrB,oFAAoF;YACtE,YAAY;IAsB1B,OAAO,CAAC,IAAI;YAQE,WAAW;IAiBzB;;;OAGG;IACH,OAAO,CAAC,uBAAuB;IA2B/B,OAAO,CAAC,QAAQ;IAKhB,OAAO,CAAC,UAAU;IAIlB,mFAAmF;YACrE,QAAQ;CAYvB;AAED,eAAe,gBAAgB,CAAA"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crowdy-file-system.test.d.ts","sourceRoot":"","sources":["../../../src/fs/crowdy-file-system.test.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * In-memory files beside the project trees: screenshots under `captures/`,
3
+ * game observations / client logs / diagnostics under `context/`.
4
+ *
5
+ * These are not project files and never reach the game API. They exist so the
6
+ * stock `read` / `read_image` tools can open what the Studio page shared,
7
+ * through the same paths the model already knows.
8
+ *
9
+ * @module @crowdedkingdoms/crowdy-dsh/fs/scratch-store
10
+ */
11
+ import type { ScratchDir } from '../crowdy/paths.js';
12
+ export interface ScratchFile {
13
+ bytes: Uint8Array;
14
+ /** Decoded text when the file is UTF-8 text; absent for binary content. */
15
+ text?: string;
16
+ version: string;
17
+ updatedAt: number;
18
+ }
19
+ export declare class ScratchStore {
20
+ private readonly dirs;
21
+ private counter;
22
+ putText(dir: ScratchDir, name: string, text: string): ScratchFile;
23
+ putBytes(dir: ScratchDir, name: string, bytes: Uint8Array): ScratchFile;
24
+ get(dir: ScratchDir, name: string): ScratchFile | undefined;
25
+ list(dir: ScratchDir): Array<{
26
+ name: string;
27
+ file: ScratchFile;
28
+ }>;
29
+ private put;
30
+ }
31
+ //# sourceMappingURL=scratch-store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scratch-store.d.ts","sourceRoot":"","sources":["../../../src/fs/scratch-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAA;AAEpD,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,UAAU,CAAA;IACjB,2EAA2E;IAC3E,IAAI,CAAC,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB;AAID,qBAAa,YAAY;IACvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAkD;IACvE,OAAO,CAAC,OAAO,CAAI;IAEnB,OAAO,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW;IAKjE,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,GAAG,WAAW;IAIvE,GAAG,CAAC,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,GAAG,WAAW,GAAG,SAAS;IAI3D,IAAI,CAAC,GAAG,EAAE,UAAU,GAAG,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,WAAW,CAAA;KAAE,CAAC;IAQjE,OAAO,CAAC,GAAG;CAyBZ"}
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Package entry: the Cordis plugin DSH mounts as `ctx.fs`, plus the sibling
3
+ * plugins a Crowdy composition inserts (search, SDK index, page bridge, tools,
4
+ * in-memory attachments). Each plugin is also reachable as a subpath export so
5
+ * a `cordis.patch.yml` row can name it directly.
6
+ *
7
+ * @module @crowdedkingdoms/crowdy-dsh
8
+ */
9
+ export { CrowdyFileSystem, default, versionOf } from './fs/crowdy-file-system.js';
10
+ export type { Config } from './fs/crowdy-file-system.js';
11
+ export { ScratchStore } from './fs/scratch-store.js';
12
+ export { CrowdyApiError, CrowdyStudioClient } from './crowdy/client.js';
13
+ export type { CrowdyFileDelete, CrowdyFileUpsert, CrowdyProject, CrowdyProjectFile, CrowdyTarget, } from './crowdy/client.js';
14
+ export { loadCrowdyConfig, describeMissing, CROWDY_CONFIG_FILENAME } from './crowdy/config.js';
15
+ export type { CrowdyBootConfig } from './crowdy/config.js';
16
+ export { GitHubProjectStore, StudioProjectStore, selectProjectStore, isSourcePath, } from './crowdy/project-store.js';
17
+ export type { ProjectSnapshot, ProjectStore } from './crowdy/project-store.js';
18
+ export { CrowdyAttachmentStore, imageDimensions } from './attachments/crowdy-attachment-store.js';
19
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,gBAAgB,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAA;AACjF,YAAY,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAA;AACxD,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AAEpD,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAA;AACvE,YAAY,EACV,gBAAgB,EAChB,gBAAgB,EAChB,aAAa,EACb,iBAAiB,EACjB,YAAY,GACb,MAAM,oBAAoB,CAAA;AAC3B,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAA;AAC9F,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAA;AAC1D,OAAO,EACL,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,GACb,MAAM,2BAA2B,CAAA;AAClC,YAAY,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAA;AAE9E,OAAO,EAAE,qBAAqB,EAAE,eAAe,EAAE,MAAM,0CAA0C,CAAA"}
@@ -0,0 +1,85 @@
1
+ /**
2
+ * Session persistence for the browser worker: mirror the harness home's
3
+ * durable state (session logs, projection caches, user settings) from the
4
+ * in-memory VFS into the origin-private file system, so a reload or a later
5
+ * visit restores the player's sessions.
6
+ *
7
+ * The page half (`web/crowdy-boot.ts`) reads the same OPFS directory before the
8
+ * worker boots and feeds it back as a pre-boot overlay, so nothing here needs
9
+ * to run before the tree is up. In Node (the developer cockpit) OPFS does not
10
+ * exist and the plugin is inert: the real disk already persists `$DSH_HOME`.
11
+ *
12
+ * @module @crowdedkingdoms/crowdy-dsh/persist
13
+ */
14
+ import type { Context } from '@deepseek-ai/cordis';
15
+ import z from '@deepseek-ai/schemastery';
16
+ export interface Config {
17
+ /**
18
+ * OPFS directory that holds this harness's mirror. The page derives it from
19
+ * the app and player so two players on one browser never share sessions.
20
+ * Also readable from `$DSH_HOME/crowdy.json` as `persistScope`.
21
+ */
22
+ scope?: string;
23
+ /** Sweep interval in milliseconds. */
24
+ intervalMs?: number;
25
+ /** Total bytes kept in the mirror; the oldest session directories go first. */
26
+ maxBytes?: number;
27
+ }
28
+ /** Cordis plugin name used by loader diagnostics. */
29
+ export declare const name = "crowdy-persist";
30
+ export declare const Config: z<Config>;
31
+ /** Home-relative trees worth keeping across reloads. */
32
+ export declare const PERSISTED_HOME_TREES: readonly ["sessions", "storages"];
33
+ /** Home-relative single files worth keeping across reloads. */
34
+ export declare const PERSISTED_HOME_FILES: readonly ["settings.yaml"];
35
+ /** Root directory name inside OPFS; scopes hang under it. */
36
+ export declare const OPFS_ROOT = "crowdy-dsh";
37
+ interface OpfsDirectory {
38
+ getDirectoryHandle(name: string, options?: {
39
+ create?: boolean;
40
+ }): Promise<OpfsDirectory>;
41
+ getFileHandle(name: string, options?: {
42
+ create?: boolean;
43
+ }): Promise<OpfsFile>;
44
+ removeEntry(name: string, options?: {
45
+ recursive?: boolean;
46
+ }): Promise<void>;
47
+ entries?(): AsyncIterableIterator<[string, OpfsDirectory | OpfsFile]>;
48
+ keys?(): AsyncIterableIterator<string>;
49
+ kind: 'directory';
50
+ }
51
+ interface OpfsFile {
52
+ kind: 'file';
53
+ createWritable(): Promise<{
54
+ write(data: Uint8Array): Promise<void>;
55
+ close(): Promise<void>;
56
+ }>;
57
+ getFile(): Promise<{
58
+ size: number;
59
+ arrayBuffer(): Promise<ArrayBuffer>;
60
+ lastModified: number;
61
+ }>;
62
+ }
63
+ /** Resolve the scope from row config, then `crowdy.json`, then a fixed default. */
64
+ export declare function resolveScope(config: Config, home: string | undefined): string;
65
+ /** Snapshot of every persisted file under the home, keyed by home-relative path. */
66
+ export declare function snapshotHome(home: string): Map<string, {
67
+ mtime: number;
68
+ size: number;
69
+ }>;
70
+ export declare class HomeMirror {
71
+ private readonly home;
72
+ private readonly scopeDir;
73
+ private readonly maxBytes;
74
+ private readonly warn;
75
+ private readonly seen;
76
+ private running;
77
+ constructor(home: string, scopeDir: Promise<OpfsDirectory>, maxBytes: number, warn: (message: string) => void);
78
+ /** Copy every file whose mtime moved since the last sweep. */
79
+ sweep(): Promise<number>;
80
+ /** Drop the oldest session directories from the mirror until under budget. */
81
+ private trim;
82
+ }
83
+ export declare function apply(ctx: Context, config?: Config): void;
84
+ export {};
85
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/persist/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAIxC,MAAM,WAAW,MAAM;IACrB;;;;OAIG;IACH,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,sCAAsC;IACtC,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB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AAC;QAAC,WAAW,IAAI,OAAO,CAAC,WAAW,CAAC,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,CAAA;CAChG;AAcD,mFAAmF;AACnF,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,CAW7E;AAsBD,oFAAoF;AACpF,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CAYvF;AAED,qBAAa,UAAU;IAKnB,OAAO,CAAC,QAAQ,CAAC,IAAI;IACrB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,QAAQ;IACzB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAPvB,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA4B;IACjD,OAAO,CAAC,OAAO,CAAQ;gBAGJ,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,OAAO,CAAC,aAAa,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI;IAGlD,8DAA8D;IACxD,KAAK,IAAI,OAAO,CAAC,MAAM,CAAC;IAgC9B,8EAA8E;YAChE,IAAI;CAwBnB;AAED,wBAAgB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,IAAI,CAmB7D"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Connectivity probe: proves the cockpit's credentials and project id reach a
3
+ * real Crowdy Studio project before the harness is booted against it.
4
+ *
5
+ * With `--write` it also performs a guarded round-trip write, which is the
6
+ * end-to-end check that the agent's edits will actually land.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=probe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"probe.d.ts","sourceRoot":"","sources":["../../../src/scripts/probe.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Closed-world `crowdy-compute-sdk` catalog: lookup, aliases, and the
3
+ * system-prompt section the agent reads instead of guessing names.
4
+ */
5
+ import { type SdkEntry } from './parse-sdk.js';
6
+ export interface SdkLookupHit {
7
+ found: boolean;
8
+ query: string;
9
+ /** Exact catalog entry when `found`. */
10
+ match?: SdkEntry;
11
+ /** Alias mapping that fired (`emit` → emit_event / emit_channel / …). */
12
+ viaAlias?: string;
13
+ /** Nearby real names when the query is not in the catalog. */
14
+ nearest: SdkEntry[];
15
+ note: string;
16
+ }
17
+ /**
18
+ * Invented names the agent has already reached for. Values are catalog
19
+ * function names (unqualified). Keep this list curated; the parser cannot
20
+ * know what the model will hallucinate.
21
+ */
22
+ export declare const SDK_ALIASES: Readonly<Record<string, readonly string[]>>;
23
+ /** Harness tool, not a WASM host function. Looking it up in the SDK is the miss. */
24
+ export declare const GAME_CONTEXT_LOOKUP_NOTE: string;
25
+ export declare const PLUGIN_HOST_LOOKUP_NOTE: string;
26
+ export declare function isPluginHostLookup(raw: string, query?: string): boolean;
27
+ export declare function isHarnessGameContextLookup(raw: string, query?: string): boolean;
28
+ /** Dice coefficient on character bigrams — enough for `emit` vs `emit_event`. */
29
+ export declare function nameSimilarity(a: string, b: string): number;
30
+ export declare function nearestEntries(catalog: readonly SdkEntry[], query: string, limit?: number): SdkEntry[];
31
+ /**
32
+ * Resolve a rustc / agent name against the catalog. Exact hits win;
33
+ * then curated aliases; then nearest real names. Never invents a function.
34
+ */
35
+ export declare function lookupSdkName(catalog: readonly SdkEntry[], raw: string): SdkLookupHit;
36
+ export declare function formatLookup(hit: SdkLookupHit): string;
37
+ /** System-prompt section: rules plus the full function index. */
38
+ export declare function formatSdkPrompt(catalog: readonly SdkEntry[]): string;
39
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cat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AAC,OAAO,EAAE,SAAS,QAAQ,EAAE,GAAG,MAAM,CAmBpE"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.test.d.ts","sourceRoot":"","sources":["../../../src/sdk-index/catalog.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Closed-world crowdy-compute-sdk index plugin.
3
+ *
4
+ * @module @crowdy/dsh-cockpit/sdk-index
5
+ */
6
+ export { apply, Config, inject, name } from './plugin.js';
7
+ export type { Config as SdkIndexConfig } from './plugin.js';
8
+ export { formatLookup, formatSdkPrompt, GAME_CONTEXT_LOOKUP_NOTE, isHarnessGameContextLookup, lookupSdkName, nearestEntries, nameSimilarity, SDK_ALIASES, } from './catalog.js';
9
+ export type { SdkLookupHit } from './catalog.js';
10
+ export { parseCrowdyComputeSdk, qualifiedName } from './parse-sdk.js';
11
+ export type { SdkEntry, SdkModule } from './parse-sdk.js';
12
+ export { SDK_SNAPSHOT, SDK_SNAPSHOT_VERSION } from './snapshot.js';
13
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/sdk-index/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,aAAa,CAAA;AACzD,YAAY,EAAE,MAAM,IAAI,cAAc,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,EACL,YAAY,EACZ,eAAe,EACf,wBAAwB,EACxB,0BAA0B,EAC1B,aAAa,EACb,cAAc,EACd,cAAc,EACd,WAAW,GACZ,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAChD,OAAO,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACrE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AACzD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAA"}
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Pull public `pub fn` entries out of `crowdy-compute-sdk` source.
3
+ *
4
+ * The crate is one file. Crate-root helpers (`log`, `state_get`, …) live
5
+ * above `pub mod api`; typed host wrappers live inside it. `impl` methods
6
+ * (Predicate::new) are skipped — they are not callable as `crowdy::api::*`.
7
+ *
8
+ * @module @crowdy/dsh-cockpit/sdk-index
9
+ */
10
+ export type SdkModule = 'crate' | 'api';
11
+ export interface SdkEntry {
12
+ name: string;
13
+ module: SdkModule;
14
+ /** Compact `fn name(...) -> Type` line, whitespace folded. */
15
+ signature: string;
16
+ /** First `///` line above the function, if any. */
17
+ doc: string;
18
+ }
19
+ /**
20
+ * Parse crate-root and `pub mod api` functions from one `lib.rs`.
21
+ */
22
+ export declare function parseCrowdyComputeSdk(source: string): SdkEntry[];
23
+ /** Path used when rustc / the seed names a function. */
24
+ export declare function qualifiedName(entry: SdkEntry): string;
25
+ //# sourceMappingURL=parse-sdk.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-sdk.d.ts","sourceRoot":"","sources":["../../../src/sdk-index/parse-sdk.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,MAAM,MAAM,SAAS,GAAG,OAAO,GAAG,KAAK,CAAA;AAEvC,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAA;IACZ,MAAM,EAAE,SAAS,CAAA;IACjB,8DAA8D;IAC9D,SAAS,EAAE,MAAM,CAAA;IACjB,mDAAmD;IACnD,GAAG,EAAE,MAAM,CAAA;CACZ;AA4CD;;GAEG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,MAAM,GAAG,QAAQ,EAAE,CA2BhE;AA2CD,wDAAwD;AACxD,wBAAgB,aAAa,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,CAErD"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Cordis plugin: inject the closed-world crowdy-compute-sdk index and a
3
+ * `sdk_lookup` tool.
4
+ *
5
+ * The Studio project does not contain the SDK crate, so grep/read cannot
6
+ * discover `crowdy::api::*`. This plugin is the swappable source of truth:
7
+ * disable the row and the agent loses the index; point `sdkSourcePath` at a
8
+ * newer `lib.rs` and the prompt rebuilds without a Studio seed change.
9
+ *
10
+ * @module @crowdy/dsh-cockpit/sdk-index
11
+ */
12
+ import type { Context } from '@deepseek-ai/cordis';
13
+ import z from '@deepseek-ai/schemastery';
14
+ export interface Config {
15
+ /**
16
+ * Optional path to `crowdy-compute-sdk/src/lib.rs`. When set, the prompt
17
+ * and lookup tool parse that file instead of the vendored 0.1.5 snapshot.
18
+ */
19
+ sdkSourcePath?: string;
20
+ }
21
+ /** Cordis plugin name used by loader diagnostics. */
22
+ export declare const name = "sdk-index-crowdy";
23
+ export declare const inject: string[];
24
+ export declare const Config: z<Config>;
25
+ export declare function apply(ctx: Context, config?: Config): Promise<void>;
26
+ //# sourceMappingURL=plugin.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../../src/sdk-index/plugin.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAGH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAQxC,MAAM,WAAW,MAAM;IACrB;;;OAGG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;CACvB;AAED,qDAAqD;AACrD,eAAO,MAAM,IAAI,qBAAqB,CAAA;AAEtC,eAAO,MAAM,MAAM,UAA4B,CAAA;AAE/C,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAI4B,CAAA;AAsBzD,wBAAsB,KAAK,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,GAAE,MAAW,GAAG,OAAO,CAAC,IAAI,CAAC,CAsD5E"}
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Vendored crowdy-compute-sdk 0.1.5 catalog.
3
+ *
4
+ * The cockpit must not import the CK API repository at runtime. When the SDK crate
5
+ * source is available, `parseCrowdyComputeSdk` can rebuild this list; tests
6
+ * compare the two so a bump without a snapshot update fails loudly.
7
+ */
8
+ import type { SdkEntry } from './parse-sdk.js';
9
+ export declare const SDK_SNAPSHOT_VERSION = "0.1.5";
10
+ export declare const SDK_SNAPSHOT: readonly SdkEntry[];
11
+ //# sourceMappingURL=snapshot.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"snapshot.d.ts","sourceRoot":"","sources":["../../../src/sdk-index/snapshot.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAA;AAE9C,eAAO,MAAM,oBAAoB,UAAU,CAAA;AAE3C,eAAO,MAAM,YAAY,EAAE,SAAS,QAAQ,EA0N3C,CAAA"}
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Minimal glob matching for the Crowdy search tools.
3
+ *
4
+ * The stock `glob`/`grep` tools hand patterns to ripgrep; the Crowdy project
5
+ * lives behind a GraphQL API, so matching happens in memory instead. This
6
+ * module implements the subset of rg's glob syntax the tools document:
7
+ * `*` (within a segment), `?`, `**` (across segments), `[...]` classes, and
8
+ * `{a,b}` alternation. Following rg, a pattern with no `/` matches the
9
+ * BASENAME at any depth, and a pattern with a separator anchors to the whole
10
+ * relative path.
11
+ *
12
+ * @module @crowdy/dsh-cockpit/search/glob-match
13
+ */
14
+ /** Thrown for a pattern the converter cannot interpret (e.g. unclosed brace). */
15
+ export declare class GlobSyntaxError extends Error {
16
+ }
17
+ /**
18
+ * Compile one glob to an anchored RegExp over a `/`-separated relative path.
19
+ * @throws {GlobSyntaxError} for an uninterpretable pattern.
20
+ */
21
+ export declare function globToRegExp(pattern: string): RegExp;
22
+ /**
23
+ * Whether a project-relative path matches one glob, following rg's rule: a
24
+ * pattern with no `/` tests the basename at any depth; a pattern with a
25
+ * separator tests the whole relative path.
26
+ *
27
+ * @param relativePath - `/`-separated path relative to the search root.
28
+ * @param pattern - the glob to test.
29
+ */
30
+ export declare function globMatches(relativePath: string, pattern: string): boolean;
31
+ //# sourceMappingURL=glob-match.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-match.d.ts","sourceRoot":"","sources":["../../../src/search/glob-match.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,iFAAiF;AACjF,qBAAa,eAAgB,SAAQ,KAAK;CAAG;AAiE7C;;;GAGG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAEpD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,YAAY,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAM1E"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"glob-match.test.d.ts","sourceRoot":"","sources":["../../../src/search/glob-match.test.ts"],"names":[],"mappings":"AAAA;;;GAGG"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * The model-facing `glob` / `grep` discovery tools for a Crowdy Studio
3
+ * project.
4
+ *
5
+ * The stock `tool-fs-search` spawns ripgrep on this machine's disk, which is
6
+ * exactly the world the crowdy preset removes: the project lives behind the
7
+ * game API, not in the launch directory. This plugin registers tools with the
8
+ * SAME names and near-identical schemas, but matching happens in memory over
9
+ * the Crowdy filesystem backend's project snapshot (`ctx.fs` must be
10
+ * {@link CrowdyFileSystem}), so search, read, and write always describe the
11
+ * same files.
12
+ *
13
+ * A Crowdy project is small (two targets, a handful of files, 64 KiB per
14
+ * file), so there is no subprocess, no spill store, and no pagination beyond
15
+ * a defensive inline cap. Returned paths are relative to the project mount,
16
+ * which is the same base the `read` tool resolves against, so every result
17
+ * is follow-up-readable.
18
+ *
19
+ * @module @crowdy/dsh-cockpit/search
20
+ */
21
+ import type { Context } from '@deepseek-ai/cordis';
22
+ import z from '@deepseek-ai/schemastery';
23
+ export interface Config {
24
+ /** Max paths one `glob` call returns inline. */
25
+ globMaxResults?: number;
26
+ /** Max matches one `grep` call returns inline. */
27
+ grepMaxMatches?: number;
28
+ /** Max bytes retained for one matched-line preview. */
29
+ grepMaxLineBytes?: number;
30
+ }
31
+ /** Cordis plugin name used by loader diagnostics. */
32
+ export declare const name = "tool-fs-search-crowdy";
33
+ /** Services required by the Crowdy search tool suite. */
34
+ export declare const inject: string[];
35
+ export declare const Config: z<Config>;
36
+ /** One file of the project snapshot the pure search core operates on. */
37
+ export interface SearchFile {
38
+ /** Virtual absolute path, e.g. `/mnt/crowdy/server/src/main.rs`. */
39
+ virtualPath: string;
40
+ content: string;
41
+ }
42
+ /** One grep hit in the canonical output shape shared with the stock tool. */
43
+ export interface GrepMatch {
44
+ path: string;
45
+ lineNumber: number;
46
+ line: string;
47
+ }
48
+ /**
49
+ * Resolve the optional `path` argument against the mount root, rejecting a
50
+ * target outside the mount so the model gets a precise message instead of a
51
+ * silent empty result.
52
+ */
53
+ export declare function resolveSearchRoot(mountRoot: string, pathArg: string | undefined): string;
54
+ /**
55
+ * Discover project files matching one glob, scoped to `searchRoot`. Matching
56
+ * follows the stock tool's rule (no `/` in the pattern = basename at any
57
+ * depth); display paths are mount-relative and returned in path order,
58
+ * because Crowdy files have no modification times.
59
+ */
60
+ export declare function globProjectPaths(files: readonly SearchFile[], mountRoot: string, searchRoot: string, pattern: string): string[];
61
+ /** Bound one matched-line preview to `maxBytes`, preserving UTF-8 boundaries. */
62
+ export declare function previewLine(line: string, maxBytes: number): string;
63
+ /**
64
+ * Search project file contents with a regular expression, scoped to
65
+ * `searchRoot` (a directory or a single file) and optionally filtered by one
66
+ * `include` glob. Lines are 1-based; a file's trailing newline does not
67
+ * produce a phantom empty line.
68
+ */
69
+ export declare function grepProjectFiles(files: readonly SearchFile[], mountRoot: string, searchRoot: string, pattern: string, include: string | undefined, maxLineBytes: number): GrepMatch[];
70
+ /** Group flat matches by file into the model-facing body. */
71
+ export declare function formatGrepMatches(matches: readonly GrepMatch[]): string;
72
+ /** Format the model-facing `grep` result, with the inline cap applied. */
73
+ export declare function renderGrepResult(matches: readonly GrepMatch[], maxMatches: number): string;
74
+ /** Format the model-facing `glob` result, with the inline cap applied. */
75
+ export declare function renderGlobResult(paths: readonly string[], maxResults: number): string;
76
+ /**
77
+ * Register the Crowdy-backed `glob` / `grep` tool suite and its system-prompt
78
+ * guidance.
79
+ */
80
+ export declare function apply(ctx: Context, config: Config): Promise<void>;
81
+ //# sourceMappingURL=search-tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-tools.d.ts","sourceRoot":"","sources":["../../../src/search/search-tools.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAA;AAClD,OAAO,CAAC,MAAM,0BAA0B,CAAA;AAaxC,MAAM,WAAW,MAAM;IACrB,gDAAgD;IAChD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,kDAAkD;IAClD,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,uDAAuD;IACvD,gBAAgB,CAAC,EAAE,MAAM,CAAA;CAC1B;AAED,qDAAqD;AACrD,eAAO,MAAM,IAAI,0BAA0B,CAAA;AAE3C,yDAAyD;AACzD,eAAO,MAAM,MAAM,UAAkC,CAAA;AAErD,eAAO,MAAM,MAAM,EAAE,CAAC,CAAC,MAAM,CAIH,CAAA;AAE1B,yEAAyE;AACzE,MAAM,WAAW,UAAU;IACzB,oEAAoE;IACpE,WAAW,EAAE,MAAM,CAAA;IACnB,OAAO,EAAE,MAAM,CAAA;CAChB;AAED,6EAA6E;AAC7E,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,IAAI,EAAE,MAAM,CAAA;CACb;AAID;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,SAAS,EAAE,MAAM,EAAE,OAAO,EAA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