@arnilo/prism-coding-agent 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -29,7 +29,7 @@ export { createMoveTool } from "./move.js";
29
29
  export type { ReadOperations, ReadTextOptions, ReadTextResult, ReadToolOptions, TransformImage, TransformImageInput, } from "./read.js";
30
30
  export { createReadTool, DEFAULT_MAX_IMAGE_BYTES, detectSupportedImageMimeType, detectSupportedImageMimeTypeFromFile, } from "./read.js";
31
31
  export type { ReadPathSet } from "./read-path-set.js";
32
- export { createReadPathSet } from "./read-path-set.js";
32
+ export { createReadPathSet, createReadPathSetPersistence, DEFAULT_MAX_PERSISTED_READ_PATHS, DEFAULT_MAX_PERSISTED_READ_PATH_CHARS, READ_PATH_SET_NAMESPACE, } from "./read-path-set.js";
33
33
  export type { RepoEntryKind, RepoListEntry, RepositoryGlobRequest, RepositoryGlobResult, RepositoryLimitOptions, RepositoryListRequest, RepositoryListResult, RepositoryOperations, RepoSearchOutputMode, RepositorySearchMatch, RepositorySearchRequest, RepositorySearchResult, ResolvedRepositoryLimits, RepositoryWalk, RepositoryWalkEvent, RepositoryWalkLimits, } from "./repository.js";
34
34
  export { compileSearchPattern, createLocalRepositoryOperations, DEFAULT_REPO_EXCLUDE, isBinaryBuffer, RepositoryError, resolveRepoPath, resolveRepositoryLimits, toRepoRelative, } from "./repository.js";
35
35
  export type { GitAwareRepositoryOptions } from "./git-aware-repository.js";
package/dist/index.js CHANGED
@@ -20,7 +20,7 @@ export { matchGlobPattern, validateGlobPattern } from "./glob-match.js";
20
20
  export { createRepoListTool } from "./list.js";
21
21
  export { createMoveTool } from "./move.js";
22
22
  export { createReadTool, DEFAULT_MAX_IMAGE_BYTES, detectSupportedImageMimeType, detectSupportedImageMimeTypeFromFile, } from "./read.js";
23
- export { createReadPathSet } from "./read-path-set.js";
23
+ export { createReadPathSet, createReadPathSetPersistence, DEFAULT_MAX_PERSISTED_READ_PATHS, DEFAULT_MAX_PERSISTED_READ_PATH_CHARS, READ_PATH_SET_NAMESPACE, } from "./read-path-set.js";
24
24
  export { compileSearchPattern, createLocalRepositoryOperations, DEFAULT_REPO_EXCLUDE, isBinaryBuffer, RepositoryError, resolveRepoPath, resolveRepositoryLimits, toRepoRelative, } from "./repository.js";
25
25
  export { createGitAwareRepositoryOperations, parseGitLsFilesZ } from "./git-aware-repository.js";
26
26
  export { applyTextEdits, createLanguageIntelligence, encodeLspFrame, LanguageIntelligenceError, LspFrameError, LspFrameReader, resolveLanguageIntelligenceLimits, } from "./language/index.js";
@@ -12,3 +12,31 @@ export interface ReadBeforeWriteOptions {
12
12
  }
13
13
  /** Returns refusal message, or null when the mutation may proceed. */
14
14
  export declare function refuseReadBeforeWrite(operation: "write" | "edit", displayPath: string, absolutePath: string, options: ReadBeforeWriteOptions | undefined, force: boolean): string | null;
15
+ /** Checkpoint namespace for the host-owned read-path set (plan 015 Task 4). */
16
+ export declare const READ_PATH_SET_NAMESPACE: "prism.coding-agent.read-path-set";
17
+ /** Persistence bounds (plan 015 Task 4): paths are names, not contents. */
18
+ export declare const DEFAULT_MAX_PERSISTED_READ_PATHS = 1024;
19
+ export declare const DEFAULT_MAX_PERSISTED_READ_PATH_CHARS = 1024;
20
+ export interface CreateReadPathSetPersistenceOptions {
21
+ /** Host-owned generic checkpoint store (ownership-scoped). */
22
+ readonly checkpoints: import("@arnilo/prism").CheckpointStore;
23
+ /** Checkpoint key, typically the session id. */
24
+ readonly key: string;
25
+ /** Ownership scope; part of the trust boundary — restore under another scope fails closed. */
26
+ readonly ownership?: import("@arnilo/prism").OwnershipScope;
27
+ /** Path-count cap (default 1024). */
28
+ readonly maxPaths?: number;
29
+ /** Per-path char cap (default 1024). */
30
+ readonly maxPathChars?: number;
31
+ }
32
+ export interface ReadPathSetPersistence {
33
+ /** Write the current set (CAS read-modify-write; conflicts surface to the host). */
34
+ save(set: ReadPathSet): Promise<void>;
35
+ /** Read persisted paths back into the set; returns how many were restored. */
36
+ restore(set: ReadPathSet): Promise<number>;
37
+ }
38
+ /**
39
+ * Opt-in persistence for the host-owned read-path set (plan 015 Task 4): names only,
40
+ * bounded, ownership-scoped, fail-closed on malformed or oversized payloads. Default off.
41
+ */
42
+ export declare function createReadPathSetPersistence(options: CreateReadPathSetPersistenceOptions): ReadPathSetPersistence;
@@ -23,4 +23,62 @@ export function refuseReadBeforeWrite(operation, displayPath, absolutePath, opti
23
23
  return null;
24
24
  return `Refusing ${operation} to ${displayPath}: not read in this session. Read first or pass force=true.`;
25
25
  }
26
+ /** Checkpoint namespace for the host-owned read-path set (plan 015 Task 4). */
27
+ export const READ_PATH_SET_NAMESPACE = "prism.coding-agent.read-path-set";
28
+ /** Persistence bounds (plan 015 Task 4): paths are names, not contents. */
29
+ export const DEFAULT_MAX_PERSISTED_READ_PATHS = 1024;
30
+ export const DEFAULT_MAX_PERSISTED_READ_PATH_CHARS = 1024;
31
+ /**
32
+ * Opt-in persistence for the host-owned read-path set (plan 015 Task 4): names only,
33
+ * bounded, ownership-scoped, fail-closed on malformed or oversized payloads. Default off.
34
+ */
35
+ export function createReadPathSetPersistence(options) {
36
+ const maxPaths = Math.max(1, options.maxPaths ?? DEFAULT_MAX_PERSISTED_READ_PATHS);
37
+ const maxPathChars = Math.max(1, options.maxPathChars ?? DEFAULT_MAX_PERSISTED_READ_PATH_CHARS);
38
+ return {
39
+ async save(set) {
40
+ const paths = set.list();
41
+ if (paths.length > maxPaths) {
42
+ throw new Error(`Read-path set exceeds ${maxPaths} persisted paths (${paths.length})`);
43
+ }
44
+ for (const path of paths) {
45
+ if (typeof path !== "string" || path.length > maxPathChars) {
46
+ throw new Error(`Read-path exceeds ${maxPathChars} chars and cannot be persisted`);
47
+ }
48
+ }
49
+ const existing = await options.checkpoints.loadCheckpoint({
50
+ namespace: READ_PATH_SET_NAMESPACE,
51
+ key: options.key,
52
+ ...options.ownership,
53
+ });
54
+ await options.checkpoints.saveCheckpoint({
55
+ namespace: READ_PATH_SET_NAMESPACE,
56
+ key: options.key,
57
+ version: (existing?.version ?? 0) + 1,
58
+ expectedVersion: existing?.version ?? 0,
59
+ value: paths,
60
+ category: "session-state",
61
+ ...options.ownership,
62
+ });
63
+ },
64
+ async restore(set) {
65
+ const record = await options.checkpoints.loadCheckpoint({
66
+ namespace: READ_PATH_SET_NAMESPACE,
67
+ key: options.key,
68
+ ...options.ownership,
69
+ });
70
+ if (!record?.value)
71
+ return 0;
72
+ const paths = record.value;
73
+ if (!Array.isArray(paths) ||
74
+ paths.length > maxPaths ||
75
+ paths.some((path) => typeof path !== "string" || path.length > maxPathChars)) {
76
+ throw new Error("Persisted read-path set is malformed or exceeds bounds; refusing to restore");
77
+ }
78
+ for (const path of paths)
79
+ set.add(path);
80
+ return paths.length;
81
+ },
82
+ };
83
+ }
26
84
  //# sourceMappingURL=read-path-set.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arnilo/prism-coding-agent",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Optional coding-agent tools (shell, read, write, edit, repo_list, repo_search, glob, delete, move, opt-in Git/check/ask-user-decision, and durable plan/checkpoint helpers) package for Prism.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -28,8 +28,8 @@
28
28
  "diff": "^9.0.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@arnilo/prism": "0.1.2",
32
- "@arnilo/prism-workflows": "0.1.2"
31
+ "@arnilo/prism": "0.1.3",
32
+ "@arnilo/prism-workflows": "0.1.3"
33
33
  },
34
34
  "devDependencies": {
35
35
  "@arnilo/prism": "file:../..",