@warlock.js/ai-workspace 5.29.0 → 5.31.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 (120) hide show
  1. package/CHANGELOG.md +68 -0
  2. package/README.md +40 -21
  3. package/cjs/index.cjs +3295 -360
  4. package/cjs/index.cjs.map +1 -1
  5. package/esm/backends/local.d.mts +1 -1
  6. package/esm/backends/local.d.mts.map +1 -1
  7. package/esm/backends/local.mjs +199 -31
  8. package/esm/backends/local.mjs.map +1 -1
  9. package/esm/backends/mock.d.mts +12 -6
  10. package/esm/backends/mock.d.mts.map +1 -1
  11. package/esm/backends/mock.mjs +45 -3
  12. package/esm/backends/mock.mjs.map +1 -1
  13. package/esm/contracts/index.d.mts +3 -3
  14. package/esm/contracts/tool-io.type.d.mts +248 -11
  15. package/esm/contracts/tool-io.type.d.mts.map +1 -1
  16. package/esm/contracts/workspace-backend.contract.d.mts +78 -2
  17. package/esm/contracts/workspace-backend.contract.d.mts.map +1 -1
  18. package/esm/contracts/workspace-ops.contract.d.mts +41 -16
  19. package/esm/contracts/workspace-ops.contract.d.mts.map +1 -1
  20. package/esm/contracts/workspace-policy.type.d.mts +142 -14
  21. package/esm/contracts/workspace-policy.type.d.mts.map +1 -1
  22. package/esm/contracts/workspace.contract.d.mts +75 -22
  23. package/esm/contracts/workspace.contract.d.mts.map +1 -1
  24. package/esm/errors.d.mts +80 -6
  25. package/esm/errors.d.mts.map +1 -1
  26. package/esm/errors.mjs +23 -2
  27. package/esm/errors.mjs.map +1 -1
  28. package/esm/index.d.mts +13 -5
  29. package/esm/index.mjs +10 -2
  30. package/esm/ops.d.mts +22 -3
  31. package/esm/ops.d.mts.map +1 -1
  32. package/esm/ops.mjs +341 -82
  33. package/esm/ops.mjs.map +1 -1
  34. package/esm/policy/jail.mjs +73 -0
  35. package/esm/policy/jail.mjs.map +1 -0
  36. package/esm/policy/policy.d.mts +26 -16
  37. package/esm/policy/policy.d.mts.map +1 -1
  38. package/esm/policy/policy.mjs +62 -86
  39. package/esm/policy/policy.mjs.map +1 -1
  40. package/esm/policy/shell-check.d.mts +64 -0
  41. package/esm/policy/shell-check.d.mts.map +1 -0
  42. package/esm/policy/shell-check.mjs +627 -0
  43. package/esm/policy/shell-check.mjs.map +1 -0
  44. package/esm/policy/shell-parser.mjs +802 -0
  45. package/esm/policy/shell-parser.mjs.map +1 -0
  46. package/esm/policy/tokenize-command.d.mts +63 -0
  47. package/esm/policy/tokenize-command.d.mts.map +1 -0
  48. package/esm/policy/tokenize-command.mjs +76 -24
  49. package/esm/policy/tokenize-command.mjs.map +1 -1
  50. package/esm/shell-jobs.d.mts +45 -0
  51. package/esm/shell-jobs.d.mts.map +1 -0
  52. package/esm/shell-jobs.mjs +247 -0
  53. package/esm/shell-jobs.mjs.map +1 -0
  54. package/esm/todos.d.mts +22 -0
  55. package/esm/todos.d.mts.map +1 -0
  56. package/esm/todos.mjs +73 -0
  57. package/esm/todos.mjs.map +1 -0
  58. package/esm/tools/edit-file.d.mts +1 -1
  59. package/esm/tools/edit-file.d.mts.map +1 -1
  60. package/esm/tools/edit-file.mjs +3 -2
  61. package/esm/tools/edit-file.mjs.map +1 -1
  62. package/esm/tools/glob.d.mts +1 -1
  63. package/esm/tools/glob.d.mts.map +1 -1
  64. package/esm/tools/glob.mjs +3 -2
  65. package/esm/tools/glob.mjs.map +1 -1
  66. package/esm/tools/grep.d.mts +1 -1
  67. package/esm/tools/grep.d.mts.map +1 -1
  68. package/esm/tools/grep.mjs +3 -2
  69. package/esm/tools/grep.mjs.map +1 -1
  70. package/esm/tools/json-schemas.mjs +175 -0
  71. package/esm/tools/json-schemas.mjs.map +1 -0
  72. package/esm/tools/list-dir.d.mts +32 -0
  73. package/esm/tools/list-dir.d.mts.map +1 -0
  74. package/esm/tools/list-dir.mjs +50 -0
  75. package/esm/tools/list-dir.mjs.map +1 -0
  76. package/esm/tools/multi-edit.d.mts +38 -0
  77. package/esm/tools/multi-edit.d.mts.map +1 -0
  78. package/esm/tools/multi-edit.mjs +121 -0
  79. package/esm/tools/multi-edit.mjs.map +1 -0
  80. package/esm/tools/read-file.d.mts +5 -5
  81. package/esm/tools/read-file.d.mts.map +1 -1
  82. package/esm/tools/read-file.mjs +10 -20
  83. package/esm/tools/read-file.mjs.map +1 -1
  84. package/esm/tools/run-shell.d.mts +39 -13
  85. package/esm/tools/run-shell.d.mts.map +1 -1
  86. package/esm/tools/run-shell.mjs +60 -47
  87. package/esm/tools/run-shell.mjs.map +1 -1
  88. package/esm/tools/run-tests.d.mts +11 -2
  89. package/esm/tools/run-tests.d.mts.map +1 -1
  90. package/esm/tools/run-tests.mjs +15 -7
  91. package/esm/tools/run-tests.mjs.map +1 -1
  92. package/esm/tools/schema.mjs +24 -19
  93. package/esm/tools/schema.mjs.map +1 -1
  94. package/esm/tools/shell-kill.d.mts +25 -0
  95. package/esm/tools/shell-kill.d.mts.map +1 -0
  96. package/esm/tools/shell-kill.mjs +36 -0
  97. package/esm/tools/shell-kill.mjs.map +1 -0
  98. package/esm/tools/shell-output.d.mts +30 -0
  99. package/esm/tools/shell-output.d.mts.map +1 -0
  100. package/esm/tools/shell-output.mjs +49 -0
  101. package/esm/tools/shell-output.mjs.map +1 -0
  102. package/esm/tools/todo.d.mts +43 -0
  103. package/esm/tools/todo.d.mts.map +1 -0
  104. package/esm/tools/todo.mjs +126 -0
  105. package/esm/tools/todo.mjs.map +1 -0
  106. package/esm/tools/write-file.d.mts +1 -1
  107. package/esm/tools/write-file.d.mts.map +1 -1
  108. package/esm/tools/write-file.mjs +3 -2
  109. package/esm/tools/write-file.mjs.map +1 -1
  110. package/esm/workspace.d.mts +12 -9
  111. package/esm/workspace.d.mts.map +1 -1
  112. package/esm/workspace.mjs +109 -28
  113. package/esm/workspace.mjs.map +1 -1
  114. package/llms-full.txt +192 -35
  115. package/llms.txt +1 -1
  116. package/package.json +5 -4
  117. package/skills/README.md +2 -2
  118. package/skills/build-loop-agent/SKILL.md +7 -7
  119. package/skills/index.md +6 -1
  120. package/skills/use-a-workspace/SKILL.md +185 -28
@@ -0,0 +1,64 @@
1
+ import { WorkspacePolicy } from "../contracts/workspace-policy.type.mjs";
2
+ import { WorkspaceShellRefusalReason } from "../errors.mjs";
3
+
4
+ //#region ../../packages/ai-workspace/src/policy/shell-check.d.ts
5
+ /** How a shell-mode line touches a path the jail has to vet. */
6
+ type WorkspaceShellPathAccess = "read" | "write" | "cwd";
7
+ /** A path a shell-mode line redirects to/from or `cd`s into. */
8
+ interface WorkspaceShellPath {
9
+ /** Absolute path, resolved lexically against the workspace root (or an earlier `cd`). */
10
+ path: string;
11
+ /** What the line does with it. */
12
+ access: WorkspaceShellPathAccess;
13
+ /** The target as written in the line. */
14
+ target: string;
15
+ }
16
+ /**
17
+ * The shell policy's verdict on one command line — see
18
+ * {@link checkShellCommand}.
19
+ */
20
+ interface WorkspaceShellCheck {
21
+ /** Whether the line may run (path targets still get a symlink-aware recheck in `exec`). */
22
+ allowed: boolean;
23
+ /** Why it was refused. */
24
+ reason?: WorkspaceShellRefusalReason;
25
+ /** Model-facing refusal text: the cause, and how to fix the command. */
26
+ message?: string;
27
+ /** The executable the refusal is about, when there is one. */
28
+ executable?: string;
29
+ /** The redirection target or `cd` directory a `"path-escape"` refusal is about. */
30
+ path?: string;
31
+ /** The argv of every simple command checked, in order (wrapped commands included). */
32
+ commands: string[][];
33
+ /** Shell mode: every redirection target and `cd` directory, for the jail recheck. */
34
+ paths: WorkspaceShellPath[];
35
+ }
36
+ /**
37
+ * The shell policy's verdict on a command line, without touching the
38
+ * filesystem.
39
+ *
40
+ * - **argv mode** (`interpreter: "none"`, the default): the line must
41
+ * tokenize into one argv; otherwise it is refused with a
42
+ * `"metacharacter"` / `"unbalanced-quotes"` reason and a message that
43
+ * names the operator and suggests the split.
44
+ * - **shell mode** (`interpreter: "sh"`): the line is parsed and every
45
+ * simple command — inside `;`, `&&`, `||`, pipes, subshells, `$( )`,
46
+ * backticks and here-documents — is checked; redirection targets and `cd`
47
+ * directories must stay in the jail (checked lexically here; `exec`
48
+ * re-checks them with symlinks resolved).
49
+ *
50
+ * Every argv goes through `deny` (case-insensitive, wins), `allow`
51
+ * (exhaustive when non-empty), `denyPatterns` and `allowCommand`.
52
+ * Wrappers (`env`, `time`, `timeout`, `nice`, `nohup`, `command`,
53
+ * `builtin`, `exec`) and `find -exec` are followed to the command they run.
54
+ * A runner the policy cannot see into (`bash -c`, `eval`, `xargs`, `sudo`,
55
+ * …) is refused while the policy has deny rules, unless `allow` names it.
56
+ *
57
+ * @example
58
+ * checkShellCommand({ cwd, shell: { allow: ["git"] } }, "git add -A && git commit -m wip");
59
+ * // { allowed: false, reason: "metacharacter", message: "`&&` is not supported in argv mode: run `git add -A`, then `git commit -m wip`, …" }
60
+ */
61
+ declare function checkShellCommand(policy: WorkspacePolicy, command: string): WorkspaceShellCheck;
62
+ //#endregion
63
+ export { WorkspaceShellCheck, WorkspaceShellPath, WorkspaceShellPathAccess, checkShellCommand };
64
+ //# sourceMappingURL=shell-check.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-check.d.mts","names":[],"sources":["../../../../../../../../packages/ai-workspace/src/policy/shell-check.ts"],"mappings":";;;;;KAmBY,wBAAA;AAAZ;AAAA,UAGiB,kBAAA;;EAEf,IAAA;EALkC;EAOlC,MAAA,EAAQ,wBAAwB;EAJC;EAMjC,MAAA;AAAA;;;;;UAOe,mBAAA;EAPT;EASN,OAAA;EAFkC;EAIlC,MAAA,GAAS,2BAAA;EAUgB;EARzB,OAAA;EAFA;EAIA,UAAA;EAFA;EAIA,IAAA;EAAA;EAEA,QAAA;EAEA;EAAA,KAAA,EAAO,kBAAkB;AAAA;;AA6hCqE;;;;;;;;;;;;;;;;;;;;;;;;iBAAhF,iBAAA,CAAkB,MAAA,EAAQ,eAAA,EAAiB,OAAA,WAAkB,mBAAmB"}