maka-agent 0.2.0-dev.30.20260912 → 0.2.0-dev.31.20260913

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 (194) hide show
  1. package/THIRD_PARTY_NOTICES.txt +392 -0
  2. package/dist/acp/maka-acp-agent.js +8 -2
  3. package/dist/acp/prompt-content.js +225 -0
  4. package/dist/acp/session-event-mapper.js +103 -0
  5. package/dist/acp/session-registry.js +654 -17
  6. package/dist/acp/stdio-server.js +10 -1
  7. package/dist/cli-core.js +1 -1
  8. package/dist/pi-transcript-tools.js +3 -2
  9. package/dist/pi-transcript.js +12 -2
  10. package/dist/runtime-host-session-channel.js +63 -9
  11. package/native/runtime-host-windows-task-launcher/prebuilds/win32-x64/maka-runtime-host-task-launcher.exe +0 -0
  12. package/node_modules/@maka/core/dist/artifacts.js +6 -0
  13. package/node_modules/@maka/core/dist/attachments.js +7 -2
  14. package/node_modules/@maka/core/dist/durable-tool-result-projection.js +3 -1
  15. package/node_modules/@maka/core/dist/events.js +21 -0
  16. package/node_modules/@maka/core/dist/goal.js +44 -2
  17. package/node_modules/@maka/core/dist/permission.js +0 -1
  18. package/node_modules/@maka/core/dist/runtime-boundary.js +73 -29
  19. package/node_modules/@maka/core/dist/runtime-event.js +6 -3
  20. package/node_modules/@maka/core/dist/runtime-handoff.js +10 -2
  21. package/node_modules/@maka/core/dist/runtime-logical-execution.js +39 -14
  22. package/node_modules/@maka/core/dist/tool-result-archive-evidence.js +3 -1
  23. package/node_modules/@maka/core/dist/tool-result-record-schema.js +2 -1
  24. package/node_modules/@maka/core/dist/unified-diff.js +33 -26
  25. package/node_modules/@maka/runtime/dist/ai-sdk-compaction.js +49 -178
  26. package/node_modules/@maka/runtime/dist/ai-sdk-message-projection.js +7 -2
  27. package/node_modules/@maka/runtime/dist/ai-sdk-turn.js +15 -53
  28. package/node_modules/@maka/runtime/dist/bash-model-output.js +7 -1
  29. package/node_modules/@maka/runtime/dist/bash-tail-buffer.js +13 -52
  30. package/node_modules/@maka/runtime/dist/builtin-tools.js +59 -111
  31. package/node_modules/@maka/runtime/dist/child-fd-input.js +3 -2
  32. package/node_modules/@maka/runtime/dist/context-budget-policy.js +1 -11
  33. package/node_modules/@maka/runtime/dist/context-budget.js +12 -1
  34. package/node_modules/@maka/runtime/dist/conversation-copy.js +104 -9
  35. package/node_modules/@maka/runtime/dist/filesystem-executor.js +10 -6
  36. package/node_modules/@maka/runtime/dist/filesystem-worker/client.js +77 -19
  37. package/node_modules/@maka/runtime/dist/filesystem-worker/launch-spec.js +66 -55
  38. package/node_modules/@maka/runtime/dist/filesystem-worker/operations.js +34 -97
  39. package/node_modules/@maka/runtime/dist/filesystem-worker/protocol.js +25 -10
  40. package/node_modules/@maka/runtime/dist/filesystem-worker/worker-entry.js +2 -0
  41. package/node_modules/@maka/runtime/dist/glob-search.js +74 -0
  42. package/node_modules/@maka/runtime/dist/goal-continuation.js +78 -8
  43. package/node_modules/@maka/runtime/dist/goal-state.js +7 -0
  44. package/node_modules/@maka/runtime/dist/grep-search.js +155 -0
  45. package/node_modules/@maka/runtime/dist/ledger-tool-result-archive-reader.js +84 -94
  46. package/node_modules/@maka/runtime/dist/model-history.js +25 -3
  47. package/node_modules/@maka/runtime/dist/pipe-tail-collector.js +6 -9
  48. package/node_modules/@maka/runtime/dist/read-page.js +231 -0
  49. package/node_modules/@maka/runtime/dist/request-projection.js +2 -15
  50. package/node_modules/@maka/runtime/dist/ripgrep-executable.js +62 -0
  51. package/node_modules/@maka/runtime/dist/ripgrep-guidance.js +81 -0
  52. package/node_modules/@maka/runtime/dist/runtime-event-read-model.js +187 -20
  53. package/node_modules/@maka/runtime/dist/runtime-read-model.js +2 -1
  54. package/node_modules/@maka/runtime/dist/sandbox/linux-profile-path.js +7 -1
  55. package/node_modules/@maka/runtime/dist/sandbox/linux-sandbox.js +20 -5
  56. package/node_modules/@maka/runtime/dist/session-manager.js +6 -6
  57. package/node_modules/@maka/runtime/dist/session-recap.js +9 -5
  58. package/node_modules/@maka/runtime/dist/shell-exec.js +7 -25
  59. package/node_modules/@maka/runtime/dist/shell-run-manager.js +1 -1
  60. package/node_modules/@maka/runtime/dist/shell-run-tool-result.js +1 -1
  61. package/node_modules/@maka/runtime/dist/shell-tools.js +6 -12
  62. package/node_modules/@maka/runtime/dist/tool-availability.js +0 -1
  63. package/node_modules/@maka/runtime/dist/tool-output.js +1 -1
  64. package/node_modules/@maka/runtime/dist/tool-result-archive-capability.js +24 -36
  65. package/node_modules/@maka/runtime/dist/tool-result-archive-resource.js +32 -527
  66. package/node_modules/@maka/runtime/dist/tool-result-archive-transition.js +17 -119
  67. package/node_modules/@maka/runtime/dist/tool-result-archive.js +7 -25
  68. package/node_modules/@maka/runtime/dist/tool-runtime.js +7 -5
  69. package/node_modules/@maka/runtime/dist/workers/filesystem-worker.js +6933 -3681
  70. package/node_modules/@maka/runtime/dist/workspace-executor.js +20 -24
  71. package/node_modules/@maka/runtime/package.json +2 -0
  72. package/node_modules/@maka/runtime-host/dist/client/host-handoff-copy.js +185 -191
  73. package/node_modules/@maka/runtime-host/dist/client/reconnecting-connection.js +3 -0
  74. package/node_modules/@maka/runtime-host/dist/protocol/index.js +5 -1
  75. package/node_modules/@maka/runtime-host/dist/protocol/message.js +2 -2
  76. package/node_modules/@maka/runtime-host/dist/protocol/operations.js +1 -0
  77. package/node_modules/@maka/runtime-host/dist/protocol/session-continuity.js +2 -2
  78. package/node_modules/@maka/runtime-host/dist/protocol/turn.js +10 -2
  79. package/node_modules/@maka/runtime-host/dist/protocol/workhub-coordination.js +38 -0
  80. package/node_modules/@maka/runtime-host/dist/server/execution-artifacts.js +2 -8
  81. package/node_modules/@maka/runtime-host/dist/server/execution-composition.js +2 -0
  82. package/node_modules/@maka/runtime-host/dist/server/goal-coordinator.js +81 -7
  83. package/node_modules/@maka/runtime-host/dist/server/hosted-execution-tool-profile.js +13 -13
  84. package/node_modules/@maka/runtime-host/dist/server/interaction-coordinator.js +65 -0
  85. package/node_modules/@maka/runtime-host/dist/server/root-turn-coordinator.js +1 -0
  86. package/node_modules/@maka/runtime-host/dist/server/session-continuity-coordinator.js +5 -2
  87. package/node_modules/@maka/runtime-host/dist/server/session-transcript-reader.js +88 -72
  88. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-action-gate.js +21 -4
  89. package/node_modules/@maka/runtime-host/dist/server/workhub-coordination-coordinator.js +145 -1
  90. package/node_modules/@maka/storage/dist/agent-run-store.js +5 -2
  91. package/node_modules/@maka/storage/dist/execution-stores.js +2 -1
  92. package/node_modules/@maka/storage/dist/runtime-transcript-query.js +27 -14
  93. package/node_modules/@maka/storage/dist/sqlite-runtime-store.js +69 -3
  94. package/node_modules/balanced-match/LICENSE.md +23 -0
  95. package/node_modules/balanced-match/README.md +57 -0
  96. package/node_modules/balanced-match/dist/commonjs/index.js +59 -0
  97. package/node_modules/balanced-match/dist/commonjs/package.json +3 -0
  98. package/node_modules/balanced-match/dist/esm/index.js +54 -0
  99. package/node_modules/balanced-match/dist/esm/package.json +3 -0
  100. package/node_modules/balanced-match/package.json +68 -0
  101. package/node_modules/brace-expansion/LICENSE +23 -0
  102. package/node_modules/brace-expansion/README.md +105 -0
  103. package/node_modules/brace-expansion/dist/commonjs/index.js +289 -0
  104. package/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
  105. package/node_modules/brace-expansion/dist/esm/index.js +285 -0
  106. package/node_modules/brace-expansion/dist/esm/package.json +3 -0
  107. package/node_modules/brace-expansion/package.json +64 -0
  108. package/node_modules/glob/LICENSE.md +63 -0
  109. package/node_modules/glob/README.md +1203 -0
  110. package/node_modules/glob/dist/commonjs/glob.js +248 -0
  111. package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
  112. package/node_modules/glob/dist/commonjs/ignore.js +119 -0
  113. package/node_modules/glob/dist/commonjs/index.js +68 -0
  114. package/node_modules/glob/dist/commonjs/index.min.js +4 -0
  115. package/node_modules/glob/dist/commonjs/package.json +3 -0
  116. package/node_modules/glob/dist/commonjs/pattern.js +223 -0
  117. package/node_modules/glob/dist/commonjs/processor.js +301 -0
  118. package/node_modules/glob/dist/commonjs/walker.js +387 -0
  119. package/node_modules/glob/dist/esm/glob.js +244 -0
  120. package/node_modules/glob/dist/esm/has-magic.js +23 -0
  121. package/node_modules/glob/dist/esm/ignore.js +115 -0
  122. package/node_modules/glob/dist/esm/index.js +55 -0
  123. package/node_modules/glob/dist/esm/index.min.js +4 -0
  124. package/node_modules/glob/dist/esm/package.json +3 -0
  125. package/node_modules/glob/dist/esm/pattern.js +219 -0
  126. package/node_modules/glob/dist/esm/processor.js +294 -0
  127. package/node_modules/glob/dist/esm/walker.js +381 -0
  128. package/node_modules/glob/package.json +98 -0
  129. package/node_modules/minimatch/LICENSE.md +55 -0
  130. package/node_modules/minimatch/README.md +528 -0
  131. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  132. package/node_modules/minimatch/dist/commonjs/ast.js +845 -0
  133. package/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
  134. package/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  135. package/node_modules/minimatch/dist/commonjs/index.js +1127 -0
  136. package/node_modules/minimatch/dist/commonjs/package.json +3 -0
  137. package/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  138. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  139. package/node_modules/minimatch/dist/esm/ast.js +841 -0
  140. package/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
  141. package/node_modules/minimatch/dist/esm/escape.js +26 -0
  142. package/node_modules/minimatch/dist/esm/index.js +1114 -0
  143. package/node_modules/minimatch/dist/esm/package.json +3 -0
  144. package/node_modules/minimatch/dist/esm/unescape.js +34 -0
  145. package/node_modules/minimatch/package.json +73 -0
  146. package/node_modules/minipass/LICENSE.md +55 -0
  147. package/node_modules/minipass/README.md +825 -0
  148. package/node_modules/minipass/dist/commonjs/index.js +1038 -0
  149. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  150. package/node_modules/minipass/dist/esm/index.js +1020 -0
  151. package/node_modules/minipass/dist/esm/package.json +3 -0
  152. package/node_modules/minipass/package.json +77 -0
  153. package/node_modules/path-scurry/LICENSE.md +55 -0
  154. package/node_modules/path-scurry/README.md +636 -0
  155. package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
  156. package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
  157. package/node_modules/path-scurry/dist/esm/index.js +1983 -0
  158. package/node_modules/path-scurry/dist/esm/package.json +3 -0
  159. package/node_modules/path-scurry/node_modules/lru-cache/LICENSE.md +55 -0
  160. package/node_modules/path-scurry/node_modules/lru-cache/README.md +469 -0
  161. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
  162. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.js +1726 -0
  163. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
  164. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.js +10 -0
  165. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
  166. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +7 -0
  167. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +1726 -0
  168. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
  169. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
  170. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.js +1726 -0
  171. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
  172. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.js +10 -0
  173. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +3 -0
  174. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.js +10 -0
  175. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
  176. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.js +1722 -0
  177. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
  178. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.js +7 -0
  179. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -0
  180. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
  181. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +1722 -0
  182. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  183. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +6 -0
  184. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.js +1722 -0
  185. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
  186. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.js +7 -0
  187. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +3 -0
  188. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.js +7 -0
  189. package/node_modules/path-scurry/node_modules/lru-cache/package.json +154 -0
  190. package/node_modules/path-scurry/package.json +72 -0
  191. package/package.json +1 -1
  192. package/node_modules/@maka/runtime/dist/active-tool-result-prune.js +0 -248
  193. package/node_modules/@maka/runtime/dist/active-tool-result-working-set.js +0 -218
  194. package/node_modules/@maka/runtime/dist/archive-read-tool.js +0 -115
@@ -0,0 +1,244 @@
1
+ import { Minimatch } from 'minimatch';
2
+ import { fileURLToPath } from 'node:url';
3
+ import { PathScurry, PathScurryDarwin, PathScurryPosix, PathScurryWin32, } from 'path-scurry';
4
+ import { Pattern } from './pattern.js';
5
+ import { GlobStream, GlobWalker } from './walker.js';
6
+ // if no process global, just call it linux.
7
+ // so we default to case-sensitive, / separators
8
+ const defaultPlatform = (typeof process === 'object' &&
9
+ process &&
10
+ typeof process.platform === 'string') ?
11
+ process.platform
12
+ : 'linux';
13
+ /**
14
+ * An object that can perform glob pattern traversals.
15
+ */
16
+ export class Glob {
17
+ absolute;
18
+ cwd;
19
+ root;
20
+ dot;
21
+ dotRelative;
22
+ follow;
23
+ ignore;
24
+ magicalBraces;
25
+ mark;
26
+ matchBase;
27
+ maxDepth;
28
+ nobrace;
29
+ nocase;
30
+ nodir;
31
+ noext;
32
+ noglobstar;
33
+ pattern;
34
+ platform;
35
+ realpath;
36
+ scurry;
37
+ stat;
38
+ signal;
39
+ windowsPathsNoEscape;
40
+ withFileTypes;
41
+ includeChildMatches;
42
+ /**
43
+ * The options provided to the constructor.
44
+ */
45
+ opts;
46
+ /**
47
+ * An array of parsed immutable {@link Pattern} objects.
48
+ */
49
+ patterns;
50
+ /**
51
+ * All options are stored as properties on the `Glob` object.
52
+ *
53
+ * See {@link GlobOptions} for full options descriptions.
54
+ *
55
+ * Note that a previous `Glob` object can be passed as the
56
+ * `GlobOptions` to another `Glob` instantiation to re-use settings
57
+ * and caches with a new pattern.
58
+ *
59
+ * Traversal functions can be called multiple times to run the walk
60
+ * again.
61
+ */
62
+ constructor(pattern, opts) {
63
+ /* c8 ignore start */
64
+ if (!opts)
65
+ throw new TypeError('glob options required');
66
+ /* c8 ignore stop */
67
+ this.withFileTypes = !!opts.withFileTypes;
68
+ this.signal = opts.signal;
69
+ this.follow = !!opts.follow;
70
+ this.dot = !!opts.dot;
71
+ this.dotRelative = !!opts.dotRelative;
72
+ this.nodir = !!opts.nodir;
73
+ this.mark = !!opts.mark;
74
+ if (!opts.cwd) {
75
+ this.cwd = '';
76
+ }
77
+ else if (opts.cwd instanceof URL || opts.cwd.startsWith('file://')) {
78
+ opts.cwd = fileURLToPath(opts.cwd);
79
+ }
80
+ this.cwd = opts.cwd || '';
81
+ this.root = opts.root;
82
+ this.magicalBraces = !!opts.magicalBraces;
83
+ this.nobrace = !!opts.nobrace;
84
+ this.noext = !!opts.noext;
85
+ this.realpath = !!opts.realpath;
86
+ this.absolute = opts.absolute;
87
+ this.includeChildMatches = opts.includeChildMatches !== false;
88
+ this.noglobstar = !!opts.noglobstar;
89
+ this.matchBase = !!opts.matchBase;
90
+ this.maxDepth =
91
+ typeof opts.maxDepth === 'number' ? opts.maxDepth : Infinity;
92
+ this.stat = !!opts.stat;
93
+ this.ignore = opts.ignore;
94
+ if (this.withFileTypes && this.absolute !== undefined) {
95
+ throw new Error('cannot set absolute and withFileTypes:true');
96
+ }
97
+ if (typeof pattern === 'string') {
98
+ pattern = [pattern];
99
+ }
100
+ this.windowsPathsNoEscape =
101
+ !!opts.windowsPathsNoEscape ||
102
+ opts.allowWindowsEscape ===
103
+ false;
104
+ if (this.windowsPathsNoEscape) {
105
+ pattern = pattern.map(p => p.replace(/\\/g, '/'));
106
+ }
107
+ if (this.matchBase) {
108
+ if (opts.noglobstar) {
109
+ throw new TypeError('base matching requires globstar');
110
+ }
111
+ pattern = pattern.map(p => (p.includes('/') ? p : `./**/${p}`));
112
+ }
113
+ this.pattern = pattern;
114
+ this.platform = opts.platform || defaultPlatform;
115
+ this.opts = { ...opts, platform: this.platform };
116
+ if (opts.scurry) {
117
+ this.scurry = opts.scurry;
118
+ if (opts.nocase !== undefined &&
119
+ opts.nocase !== opts.scurry.nocase) {
120
+ throw new Error('nocase option contradicts provided scurry option');
121
+ }
122
+ }
123
+ else {
124
+ const Scurry = opts.platform === 'win32' ? PathScurryWin32
125
+ : opts.platform === 'darwin' ? PathScurryDarwin
126
+ : opts.platform ? PathScurryPosix
127
+ : PathScurry;
128
+ this.scurry = new Scurry(this.cwd, {
129
+ nocase: opts.nocase,
130
+ fs: opts.fs,
131
+ });
132
+ }
133
+ this.nocase = this.scurry.nocase;
134
+ // If you do nocase:true on a case-sensitive file system, then
135
+ // we need to use regexps instead of strings for non-magic
136
+ // path portions, because statting `aBc` won't return results
137
+ // for the file `AbC` for example.
138
+ const nocaseMagicOnly = this.platform === 'darwin' || this.platform === 'win32';
139
+ const mmo = {
140
+ braceExpandMax: 10_000,
141
+ ...opts,
142
+ dot: this.dot,
143
+ matchBase: this.matchBase,
144
+ nobrace: this.nobrace,
145
+ // default nocase based on platform
146
+ nocase: this.nocase,
147
+ nocaseMagicOnly,
148
+ nocomment: true,
149
+ noext: this.noext,
150
+ nonegate: true,
151
+ optimizationLevel: 2,
152
+ platform: this.platform,
153
+ windowsPathsNoEscape: this.windowsPathsNoEscape,
154
+ debug: !!this.opts.debug,
155
+ };
156
+ const mms = this.pattern.map(p => new Minimatch(p, mmo));
157
+ const [matchSet, globParts] = mms.reduce((set, m) => {
158
+ set[0].push(...m.set);
159
+ set[1].push(...m.globParts);
160
+ return set;
161
+ }, [[], []]);
162
+ this.patterns = matchSet.map((set, i) => {
163
+ const g = globParts[i];
164
+ /* c8 ignore start */
165
+ if (!g)
166
+ throw new Error('invalid pattern object');
167
+ /* c8 ignore stop */
168
+ return new Pattern(set, g, 0, this.platform);
169
+ });
170
+ }
171
+ async walk() {
172
+ // Walkers always return array of Path objects, so we just have to
173
+ // coerce them into the right shape. It will have already called
174
+ // realpath() if the option was set to do so, so we know that's cached.
175
+ // start out knowing the cwd, at least
176
+ return [
177
+ ...(await new GlobWalker(this.patterns, this.scurry.cwd, {
178
+ ...this.opts,
179
+ maxDepth: this.maxDepth !== Infinity ?
180
+ this.maxDepth + this.scurry.cwd.depth()
181
+ : Infinity,
182
+ platform: this.platform,
183
+ nocase: this.nocase,
184
+ includeChildMatches: this.includeChildMatches,
185
+ }).walk()),
186
+ ];
187
+ }
188
+ walkSync() {
189
+ return [
190
+ ...new GlobWalker(this.patterns, this.scurry.cwd, {
191
+ ...this.opts,
192
+ maxDepth: this.maxDepth !== Infinity ?
193
+ this.maxDepth + this.scurry.cwd.depth()
194
+ : Infinity,
195
+ platform: this.platform,
196
+ nocase: this.nocase,
197
+ includeChildMatches: this.includeChildMatches,
198
+ }).walkSync(),
199
+ ];
200
+ }
201
+ stream() {
202
+ return new GlobStream(this.patterns, this.scurry.cwd, {
203
+ ...this.opts,
204
+ maxDepth: this.maxDepth !== Infinity ?
205
+ this.maxDepth + this.scurry.cwd.depth()
206
+ : Infinity,
207
+ platform: this.platform,
208
+ nocase: this.nocase,
209
+ includeChildMatches: this.includeChildMatches,
210
+ }).stream();
211
+ }
212
+ streamSync() {
213
+ return new GlobStream(this.patterns, this.scurry.cwd, {
214
+ ...this.opts,
215
+ maxDepth: this.maxDepth !== Infinity ?
216
+ this.maxDepth + this.scurry.cwd.depth()
217
+ : Infinity,
218
+ platform: this.platform,
219
+ nocase: this.nocase,
220
+ includeChildMatches: this.includeChildMatches,
221
+ }).streamSync();
222
+ }
223
+ /**
224
+ * Default sync iteration function. Returns a Generator that
225
+ * iterates over the results.
226
+ */
227
+ iterateSync() {
228
+ return this.streamSync()[Symbol.iterator]();
229
+ }
230
+ [Symbol.iterator]() {
231
+ return this.iterateSync();
232
+ }
233
+ /**
234
+ * Default async iteration function. Returns an AsyncGenerator that
235
+ * iterates over the results.
236
+ */
237
+ iterate() {
238
+ return this.stream()[Symbol.asyncIterator]();
239
+ }
240
+ [Symbol.asyncIterator]() {
241
+ return this.iterate();
242
+ }
243
+ }
244
+ //# sourceMappingURL=glob.js.map
@@ -0,0 +1,23 @@
1
+ import { Minimatch } from 'minimatch';
2
+ /**
3
+ * Return true if the patterns provided contain any magic glob characters,
4
+ * given the options provided.
5
+ *
6
+ * Brace expansion is not considered "magic" unless the `magicalBraces` option
7
+ * is set, as brace expansion just turns one string into an array of strings.
8
+ * So a pattern like `'x{a,b}y'` would return `false`, because `'xay'` and
9
+ * `'xby'` both do not contain any magic glob characters, and it's treated the
10
+ * same as if you had called it on `['xay', 'xby']`. When `magicalBraces:true`
11
+ * is in the options, brace expansion _is_ treated as a pattern having magic.
12
+ */
13
+ export const hasMagic = (pattern, options = {}) => {
14
+ if (!Array.isArray(pattern)) {
15
+ pattern = [pattern];
16
+ }
17
+ for (const p of pattern) {
18
+ if (new Minimatch(p, options).hasMagic())
19
+ return true;
20
+ }
21
+ return false;
22
+ };
23
+ //# sourceMappingURL=has-magic.js.map
@@ -0,0 +1,115 @@
1
+ // give it a pattern, and it'll be able to tell you if
2
+ // a given path should be ignored.
3
+ // Ignoring a path ignores its children if the pattern ends in /**
4
+ // Ignores are always parsed in dot:true mode
5
+ import { Minimatch } from 'minimatch';
6
+ import { Pattern } from './pattern.js';
7
+ const defaultPlatform = (typeof process === 'object' &&
8
+ process &&
9
+ typeof process.platform === 'string') ?
10
+ process.platform
11
+ : 'linux';
12
+ /**
13
+ * Class used to process ignored patterns
14
+ */
15
+ export class Ignore {
16
+ relative;
17
+ relativeChildren;
18
+ absolute;
19
+ absoluteChildren;
20
+ platform;
21
+ mmopts;
22
+ constructor(ignored, { nobrace, nocase, noext, noglobstar, platform = defaultPlatform, }) {
23
+ this.relative = [];
24
+ this.absolute = [];
25
+ this.relativeChildren = [];
26
+ this.absoluteChildren = [];
27
+ this.platform = platform;
28
+ this.mmopts = {
29
+ dot: true,
30
+ nobrace,
31
+ nocase,
32
+ noext,
33
+ noglobstar,
34
+ optimizationLevel: 2,
35
+ platform,
36
+ nocomment: true,
37
+ nonegate: true,
38
+ };
39
+ for (const ign of ignored)
40
+ this.add(ign);
41
+ }
42
+ add(ign) {
43
+ // this is a little weird, but it gives us a clean set of optimized
44
+ // minimatch matchers, without getting tripped up if one of them
45
+ // ends in /** inside a brace section, and it's only inefficient at
46
+ // the start of the walk, not along it.
47
+ // It'd be nice if the Pattern class just had a .test() method, but
48
+ // handling globstars is a bit of a pita, and that code already lives
49
+ // in minimatch anyway.
50
+ // Another way would be if maybe Minimatch could take its set/globParts
51
+ // as an option, and then we could at least just use Pattern to test
52
+ // for absolute-ness.
53
+ // Yet another way, Minimatch could take an array of glob strings, and
54
+ // a cwd option, and do the right thing.
55
+ const mm = new Minimatch(ign, this.mmopts);
56
+ for (let i = 0; i < mm.set.length; i++) {
57
+ const parsed = mm.set[i];
58
+ const globParts = mm.globParts[i];
59
+ /* c8 ignore start */
60
+ if (!parsed || !globParts) {
61
+ throw new Error('invalid pattern object');
62
+ }
63
+ // strip off leading ./ portions
64
+ // https://github.com/isaacs/node-glob/issues/570
65
+ while (parsed[0] === '.' && globParts[0] === '.') {
66
+ parsed.shift();
67
+ globParts.shift();
68
+ }
69
+ /* c8 ignore stop */
70
+ const p = new Pattern(parsed, globParts, 0, this.platform);
71
+ const m = new Minimatch(p.globString(), this.mmopts);
72
+ const children = globParts[globParts.length - 1] === '**';
73
+ const absolute = p.isAbsolute();
74
+ if (absolute)
75
+ this.absolute.push(m);
76
+ else
77
+ this.relative.push(m);
78
+ if (children) {
79
+ if (absolute)
80
+ this.absoluteChildren.push(m);
81
+ else
82
+ this.relativeChildren.push(m);
83
+ }
84
+ }
85
+ }
86
+ ignored(p) {
87
+ const fullpath = p.fullpath();
88
+ const fullpaths = `${fullpath}/`;
89
+ const relative = p.relative() || '.';
90
+ const relatives = `${relative}/`;
91
+ for (const m of this.relative) {
92
+ if (m.match(relative) || m.match(relatives))
93
+ return true;
94
+ }
95
+ for (const m of this.absolute) {
96
+ if (m.match(fullpath) || m.match(fullpaths))
97
+ return true;
98
+ }
99
+ return false;
100
+ }
101
+ childrenIgnored(p) {
102
+ const fullpath = p.fullpath() + '/';
103
+ const relative = (p.relative() || '.') + '/';
104
+ for (const m of this.relativeChildren) {
105
+ if (m.match(relative))
106
+ return true;
107
+ }
108
+ for (const m of this.absoluteChildren) {
109
+ if (m.match(fullpath))
110
+ return true;
111
+ }
112
+ return false;
113
+ }
114
+ }
115
+ //# sourceMappingURL=ignore.js.map
@@ -0,0 +1,55 @@
1
+ import { escape, unescape } from 'minimatch';
2
+ import { Glob } from './glob.js';
3
+ import { hasMagic } from './has-magic.js';
4
+ export { escape, unescape } from 'minimatch';
5
+ export { Glob } from './glob.js';
6
+ export { hasMagic } from './has-magic.js';
7
+ export { Ignore } from './ignore.js';
8
+ export function globStreamSync(pattern, options = {}) {
9
+ return new Glob(pattern, options).streamSync();
10
+ }
11
+ export function globStream(pattern, options = {}) {
12
+ return new Glob(pattern, options).stream();
13
+ }
14
+ export function globSync(pattern, options = {}) {
15
+ return new Glob(pattern, options).walkSync();
16
+ }
17
+ async function glob_(pattern, options = {}) {
18
+ return new Glob(pattern, options).walk();
19
+ }
20
+ export function globIterateSync(pattern, options = {}) {
21
+ return new Glob(pattern, options).iterateSync();
22
+ }
23
+ export function globIterate(pattern, options = {}) {
24
+ return new Glob(pattern, options).iterate();
25
+ }
26
+ // aliases: glob.sync.stream() glob.stream.sync() glob.sync() etc
27
+ export const streamSync = globStreamSync;
28
+ export const stream = Object.assign(globStream, { sync: globStreamSync });
29
+ export const iterateSync = globIterateSync;
30
+ export const iterate = Object.assign(globIterate, {
31
+ sync: globIterateSync,
32
+ });
33
+ export const sync = Object.assign(globSync, {
34
+ stream: globStreamSync,
35
+ iterate: globIterateSync,
36
+ });
37
+ export const glob = Object.assign(glob_, {
38
+ glob: glob_,
39
+ globSync,
40
+ sync,
41
+ globStream,
42
+ stream,
43
+ globStreamSync,
44
+ streamSync,
45
+ globIterate,
46
+ iterate,
47
+ globIterateSync,
48
+ iterateSync,
49
+ Glob,
50
+ hasMagic,
51
+ escape,
52
+ unescape,
53
+ });
54
+ glob.glob = glob;
55
+ //# sourceMappingURL=index.js.map