@joshski/dust 0.1.108 → 0.1.110

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,2 @@
1
+ export declare function isErrnoException(error: unknown): error is NodeJS.ErrnoException;
2
+ export declare function isErrorCode(error: unknown, code: string): boolean;
@@ -7,7 +7,7 @@ import type { CommandDependencies } from '../cli/types';
7
7
  import { type InvalidTask, type UnblockedTask } from '../cli/commands/next';
8
8
  import type { LoopEmitFn } from './events';
9
9
  import type { PostEventFn, SendAgentEventFn } from './wire-events';
10
- export declare const DUST_QUICK_REFERENCE = "## Dust Quick Reference\n\nDust stores project context in `.dust/` as markdown artifacts. Use these commands to explore:\n\n- `dust ideas` \u2014 list ideas for future work\n- `dust principles` \u2014 show guiding values and design constraints\n- `dust facts` \u2014 show current state documentation\n- `dust help` \u2014 see all available commands\n\nUse dust commands instead of manually searching `.dust/` directories.";
10
+ export declare function DUST_QUICK_REFERENCE(dustCommand: string): string;
11
11
  export interface LoopDependencies {
12
12
  spawn: typeof nodeSpawn;
13
13
  run: BoundRunFn;
@@ -46,5 +46,5 @@ export declare function findAvailableTasks(dependencies: CommandDependencies): P
46
46
  invalidTasks: InvalidTask[];
47
47
  }>;
48
48
  export declare function runOneIteration(dependencies: CommandDependencies, loopDependencies: LoopDependencies, onLoopEvent: LoopEmitFn, onAgentEvent?: SendAgentEventFn, options?: IterationOptions): Promise<IterationResult>;
49
- export declare function buildTaskPrompt(taskPath: string, taskContent: string, instructions: string, toolsSection: string, branch?: string): string;
49
+ export declare function buildTaskPrompt(taskPath: string, taskContent: string, instructions: string, toolsSection: string, dustCommand: string, branch?: string): string;
50
50
  export {};
package/dist/patch.js CHANGED
@@ -158,8 +158,16 @@ var ARTIFACT_TYPES = [
158
158
  "tasks"
159
159
  ];
160
160
 
161
+ // lib/filesystem/error-codes.ts
162
+ function isErrnoException(error) {
163
+ return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string";
164
+ }
165
+ function isErrorCode(error, code) {
166
+ return isErrnoException(error) && error.code === code;
167
+ }
168
+
161
169
  // lib/validation/index.ts
162
- import { relative } from "node:path";
170
+ import { relative, resolve as resolve3 } from "node:path";
163
171
 
164
172
  // lib/validation/overlay-filesystem.ts
165
173
  function createOverlayFileSystem(base, patchFiles, deletedPaths = new Set) {
@@ -212,7 +220,7 @@ function createOverlayFileSystem(base, patchFiles, deletedPaths = new Set) {
212
220
  }
213
221
  }
214
222
  } catch (error) {
215
- if (error.code !== "ENOENT") {
223
+ if (!isErrorCode(error, "ENOENT")) {
216
224
  throw error;
217
225
  }
218
226
  }
@@ -349,7 +357,7 @@ async function validateContentDirectoryFiles(dirPath, fileSystem) {
349
357
  try {
350
358
  entries = await fileSystem.readdir(dirPath);
351
359
  } catch (error) {
352
- if (error.code === "ENOENT") {
360
+ if (isErrorCode(error, "ENOENT")) {
353
361
  return [];
354
362
  }
355
363
  throw error;
@@ -770,7 +778,7 @@ async function parseArtifacts(fileSystem, dustPath) {
770
778
  try {
771
779
  rootEntries = await fileSystem.readdir(dustPath);
772
780
  } catch (error) {
773
- if (error.code === "ENOENT") {
781
+ if (isErrorCode(error, "ENOENT")) {
774
782
  rootEntries = [];
775
783
  } else {
776
784
  throw error;
@@ -784,7 +792,7 @@ async function parseArtifacts(fileSystem, dustPath) {
784
792
  try {
785
793
  content = await fileSystem.readFile(filePath);
786
794
  } catch (error) {
787
- if (error.code === "ENOENT") {
795
+ if (isErrorCode(error, "ENOENT")) {
788
796
  continue;
789
797
  }
790
798
  throw error;
@@ -800,7 +808,7 @@ async function parseArtifacts(fileSystem, dustPath) {
800
808
  try {
801
809
  entries = await fileSystem.readdir(dirPath);
802
810
  } catch (error) {
803
- if (error.code === "ENOENT") {
811
+ if (isErrorCode(error, "ENOENT")) {
804
812
  continue;
805
813
  }
806
814
  throw error;
@@ -828,7 +836,7 @@ async function parseArtifacts(fileSystem, dustPath) {
828
836
  try {
829
837
  auditEntries = await fileSystem.readdir(auditsPath);
830
838
  } catch (error) {
831
- if (error.code === "ENOENT") {
839
+ if (isErrorCode(error, "ENOENT")) {
832
840
  auditEntries = [];
833
841
  } else {
834
842
  throw error;
@@ -842,7 +850,7 @@ async function parseArtifacts(fileSystem, dustPath) {
842
850
  try {
843
851
  content = await fileSystem.readFile(filePath);
844
852
  } catch (error) {
845
- if (error.code === "ENOENT") {
853
+ if (isErrorCode(error, "ENOENT")) {
846
854
  continue;
847
855
  }
848
856
  throw error;
@@ -995,11 +1003,12 @@ function parsePatchFiles(dustPath, patch) {
995
1003
  }
996
1004
  async function validatePatch(fileSystem, dustPath, patch, options = {}) {
997
1005
  const cwd = options.cwd ?? process.cwd();
998
- const { absolutePatchFiles, deletedPaths } = parsePatchFiles(dustPath, patch);
1006
+ const resolvedDustPath = resolve3(dustPath);
1007
+ const { absolutePatchFiles, deletedPaths } = parsePatchFiles(resolvedDustPath, patch);
999
1008
  const overlayFs = createOverlayFileSystem(fileSystem, absolutePatchFiles, deletedPaths);
1000
1009
  const violations = [];
1001
- violations.push(...validatePatchRootEntries(fileSystem, dustPath, patch));
1002
- const { context, violations: parseViolations } = await parseArtifacts(overlayFs, dustPath);
1010
+ violations.push(...validatePatchRootEntries(fileSystem, resolvedDustPath, patch));
1011
+ const { context, violations: parseViolations } = await parseArtifacts(overlayFs, resolvedDustPath);
1003
1012
  violations.push(...parseViolations);
1004
1013
  violations.push(...validateArtifacts(context));
1005
1014
  return {
@@ -1278,7 +1287,7 @@ async function loadExistingPrincipleRelationships(fileSystem, dustPath) {
1278
1287
  try {
1279
1288
  entries = await fileSystem.readdir(principlesDir);
1280
1289
  } catch (error) {
1281
- if (error.code === "ENOENT") {
1290
+ if (isErrorCode(error, "ENOENT")) {
1282
1291
  return relationships;
1283
1292
  }
1284
1293
  throw error;
@@ -1393,7 +1402,7 @@ async function findReferencesToDeletedPaths(fileSystem, dustPath, deletedPaths)
1393
1402
  try {
1394
1403
  entries = await fileSystem.readdir(dirPath);
1395
1404
  } catch (error) {
1396
- if (error.code === "ENOENT") {
1405
+ if (isErrorCode(error, "ENOENT")) {
1397
1406
  continue;
1398
1407
  }
1399
1408
  throw error;
@@ -1559,7 +1568,7 @@ async function fileExists(fileSystem, path) {
1559
1568
  await fileSystem.readFile(path);
1560
1569
  return true;
1561
1570
  } catch (error) {
1562
- if (error.code === "ENOENT") {
1571
+ if (isErrorCode(error, "ENOENT")) {
1563
1572
  return false;
1564
1573
  }
1565
1574
  throw error;
@@ -1,5 +1,13 @@
1
1
  // lib/validation/index.ts
2
- import { relative } from "node:path";
2
+ import { relative, resolve as resolve3 } from "node:path";
3
+
4
+ // lib/filesystem/error-codes.ts
5
+ function isErrnoException(error) {
6
+ return typeof error === "object" && error !== null && "code" in error && typeof error.code === "string";
7
+ }
8
+ function isErrorCode(error, code) {
9
+ return isErrnoException(error) && error.code === code;
10
+ }
3
11
 
4
12
  // lib/validation/overlay-filesystem.ts
5
13
  function createOverlayFileSystem(base, patchFiles, deletedPaths = new Set) {
@@ -52,7 +60,7 @@ function createOverlayFileSystem(base, patchFiles, deletedPaths = new Set) {
52
60
  }
53
61
  }
54
62
  } catch (error) {
55
- if (error.code !== "ENOENT") {
63
+ if (!isErrorCode(error, "ENOENT")) {
56
64
  throw error;
57
65
  }
58
66
  }
@@ -346,7 +354,7 @@ async function validateContentDirectoryFiles(dirPath, fileSystem) {
346
354
  try {
347
355
  entries = await fileSystem.readdir(dirPath);
348
356
  } catch (error) {
349
- if (error.code === "ENOENT") {
357
+ if (isErrorCode(error, "ENOENT")) {
350
358
  return [];
351
359
  }
352
360
  throw error;
@@ -767,7 +775,7 @@ async function parseArtifacts(fileSystem, dustPath) {
767
775
  try {
768
776
  rootEntries = await fileSystem.readdir(dustPath);
769
777
  } catch (error) {
770
- if (error.code === "ENOENT") {
778
+ if (isErrorCode(error, "ENOENT")) {
771
779
  rootEntries = [];
772
780
  } else {
773
781
  throw error;
@@ -781,7 +789,7 @@ async function parseArtifacts(fileSystem, dustPath) {
781
789
  try {
782
790
  content = await fileSystem.readFile(filePath);
783
791
  } catch (error) {
784
- if (error.code === "ENOENT") {
792
+ if (isErrorCode(error, "ENOENT")) {
785
793
  continue;
786
794
  }
787
795
  throw error;
@@ -797,7 +805,7 @@ async function parseArtifacts(fileSystem, dustPath) {
797
805
  try {
798
806
  entries = await fileSystem.readdir(dirPath);
799
807
  } catch (error) {
800
- if (error.code === "ENOENT") {
808
+ if (isErrorCode(error, "ENOENT")) {
801
809
  continue;
802
810
  }
803
811
  throw error;
@@ -825,7 +833,7 @@ async function parseArtifacts(fileSystem, dustPath) {
825
833
  try {
826
834
  auditEntries = await fileSystem.readdir(auditsPath);
827
835
  } catch (error) {
828
- if (error.code === "ENOENT") {
836
+ if (isErrorCode(error, "ENOENT")) {
829
837
  auditEntries = [];
830
838
  } else {
831
839
  throw error;
@@ -839,7 +847,7 @@ async function parseArtifacts(fileSystem, dustPath) {
839
847
  try {
840
848
  content = await fileSystem.readFile(filePath);
841
849
  } catch (error) {
842
- if (error.code === "ENOENT") {
850
+ if (isErrorCode(error, "ENOENT")) {
843
851
  continue;
844
852
  }
845
853
  throw error;
@@ -992,11 +1000,12 @@ function parsePatchFiles(dustPath, patch) {
992
1000
  }
993
1001
  async function validatePatch(fileSystem, dustPath, patch, options = {}) {
994
1002
  const cwd = options.cwd ?? process.cwd();
995
- const { absolutePatchFiles, deletedPaths } = parsePatchFiles(dustPath, patch);
1003
+ const resolvedDustPath = resolve3(dustPath);
1004
+ const { absolutePatchFiles, deletedPaths } = parsePatchFiles(resolvedDustPath, patch);
996
1005
  const overlayFs = createOverlayFileSystem(fileSystem, absolutePatchFiles, deletedPaths);
997
1006
  const violations = [];
998
- violations.push(...validatePatchRootEntries(fileSystem, dustPath, patch));
999
- const { context, violations: parseViolations } = await parseArtifacts(overlayFs, dustPath);
1007
+ violations.push(...validatePatchRootEntries(fileSystem, resolvedDustPath, patch));
1008
+ const { context, violations: parseViolations } = await parseArtifacts(overlayFs, resolvedDustPath);
1000
1009
  violations.push(...parseViolations);
1001
1010
  violations.push(...validateArtifacts(context));
1002
1011
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@joshski/dust",
3
- "version": "0.1.108",
3
+ "version": "0.1.110",
4
4
  "description": "Flow state for AI coding agents",
5
5
  "type": "module",
6
6
  "bin": {