aicodeman 0.2.8
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/LICENSE +21 -0
- package/README.md +403 -0
- package/dist/ai-checker-base.d.ts +175 -0
- package/dist/ai-checker-base.d.ts.map +1 -0
- package/dist/ai-checker-base.js +424 -0
- package/dist/ai-checker-base.js.map +1 -0
- package/dist/ai-idle-checker.d.ts +53 -0
- package/dist/ai-idle-checker.d.ts.map +1 -0
- package/dist/ai-idle-checker.js +141 -0
- package/dist/ai-idle-checker.js.map +1 -0
- package/dist/ai-plan-checker.d.ts +52 -0
- package/dist/ai-plan-checker.d.ts.map +1 -0
- package/dist/ai-plan-checker.js +103 -0
- package/dist/ai-plan-checker.js.map +1 -0
- package/dist/bash-tool-parser.d.ts +191 -0
- package/dist/bash-tool-parser.d.ts.map +1 -0
- package/dist/bash-tool-parser.js +598 -0
- package/dist/bash-tool-parser.js.map +1 -0
- package/dist/cli.d.ts +12 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +460 -0
- package/dist/cli.js.map +1 -0
- package/dist/config/buffer-limits.d.ts +59 -0
- package/dist/config/buffer-limits.d.ts.map +1 -0
- package/dist/config/buffer-limits.js +74 -0
- package/dist/config/buffer-limits.js.map +1 -0
- package/dist/config/map-limits.d.ts +40 -0
- package/dist/config/map-limits.d.ts.map +1 -0
- package/dist/config/map-limits.js +52 -0
- package/dist/config/map-limits.js.map +1 -0
- package/dist/file-stream-manager.d.ts +148 -0
- package/dist/file-stream-manager.d.ts.map +1 -0
- package/dist/file-stream-manager.js +351 -0
- package/dist/file-stream-manager.js.map +1 -0
- package/dist/hooks-config.d.ts +31 -0
- package/dist/hooks-config.d.ts.map +1 -0
- package/dist/hooks-config.js +115 -0
- package/dist/hooks-config.js.map +1 -0
- package/dist/image-watcher.d.ts +86 -0
- package/dist/image-watcher.d.ts.map +1 -0
- package/dist/image-watcher.js +275 -0
- package/dist/image-watcher.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +54 -0
- package/dist/index.js.map +1 -0
- package/dist/mux-factory.d.ts +13 -0
- package/dist/mux-factory.d.ts.map +1 -0
- package/dist/mux-factory.js +19 -0
- package/dist/mux-factory.js.map +1 -0
- package/dist/mux-interface.d.ts +145 -0
- package/dist/mux-interface.d.ts.map +1 -0
- package/dist/mux-interface.js +9 -0
- package/dist/mux-interface.js.map +1 -0
- package/dist/plan-orchestrator.d.ts +123 -0
- package/dist/plan-orchestrator.d.ts.map +1 -0
- package/dist/plan-orchestrator.js +500 -0
- package/dist/plan-orchestrator.js.map +1 -0
- package/dist/prompts/index.d.ts +9 -0
- package/dist/prompts/index.d.ts.map +1 -0
- package/dist/prompts/index.js +9 -0
- package/dist/prompts/index.js.map +1 -0
- package/dist/prompts/planner.d.ts +14 -0
- package/dist/prompts/planner.d.ts.map +1 -0
- package/dist/prompts/planner.js +83 -0
- package/dist/prompts/planner.js.map +1 -0
- package/dist/prompts/research-agent.d.ts +10 -0
- package/dist/prompts/research-agent.d.ts.map +1 -0
- package/dist/prompts/research-agent.js +143 -0
- package/dist/prompts/research-agent.js.map +1 -0
- package/dist/push-store.d.ts +41 -0
- package/dist/push-store.d.ts.map +1 -0
- package/dist/push-store.js +168 -0
- package/dist/push-store.js.map +1 -0
- package/dist/ralph-config.d.ts +67 -0
- package/dist/ralph-config.d.ts.map +1 -0
- package/dist/ralph-config.js +134 -0
- package/dist/ralph-config.js.map +1 -0
- package/dist/ralph-loop.d.ts +124 -0
- package/dist/ralph-loop.d.ts.map +1 -0
- package/dist/ralph-loop.js +418 -0
- package/dist/ralph-loop.js.map +1 -0
- package/dist/ralph-tracker.d.ts +1081 -0
- package/dist/ralph-tracker.d.ts.map +1 -0
- package/dist/ralph-tracker.js +3343 -0
- package/dist/ralph-tracker.js.map +1 -0
- package/dist/respawn-controller.d.ts +1182 -0
- package/dist/respawn-controller.d.ts.map +1 -0
- package/dist/respawn-controller.js +2754 -0
- package/dist/respawn-controller.js.map +1 -0
- package/dist/run-summary.d.ts +123 -0
- package/dist/run-summary.d.ts.map +1 -0
- package/dist/run-summary.js +325 -0
- package/dist/run-summary.js.map +1 -0
- package/dist/session-lifecycle-log.d.ts +36 -0
- package/dist/session-lifecycle-log.d.ts.map +1 -0
- package/dist/session-lifecycle-log.js +101 -0
- package/dist/session-lifecycle-log.js.map +1 -0
- package/dist/session-manager.d.ts +97 -0
- package/dist/session-manager.d.ts.map +1 -0
- package/dist/session-manager.js +224 -0
- package/dist/session-manager.js.map +1 -0
- package/dist/session.d.ts +686 -0
- package/dist/session.d.ts.map +1 -0
- package/dist/session.js +2025 -0
- package/dist/session.js.map +1 -0
- package/dist/state-store.d.ts +189 -0
- package/dist/state-store.d.ts.map +1 -0
- package/dist/state-store.js +730 -0
- package/dist/state-store.js.map +1 -0
- package/dist/subagent-watcher.d.ts +345 -0
- package/dist/subagent-watcher.d.ts.map +1 -0
- package/dist/subagent-watcher.js +1469 -0
- package/dist/subagent-watcher.js.map +1 -0
- package/dist/task-queue.d.ts +108 -0
- package/dist/task-queue.d.ts.map +1 -0
- package/dist/task-queue.js +235 -0
- package/dist/task-queue.js.map +1 -0
- package/dist/task-tracker.d.ts +306 -0
- package/dist/task-tracker.d.ts.map +1 -0
- package/dist/task-tracker.js +488 -0
- package/dist/task-tracker.js.map +1 -0
- package/dist/task.d.ts +73 -0
- package/dist/task.d.ts.map +1 -0
- package/dist/task.js +177 -0
- package/dist/task.js.map +1 -0
- package/dist/team-watcher.d.ts +53 -0
- package/dist/team-watcher.d.ts.map +1 -0
- package/dist/team-watcher.js +313 -0
- package/dist/team-watcher.js.map +1 -0
- package/dist/templates/case-template.md +461 -0
- package/dist/templates/claude-md.d.ts +26 -0
- package/dist/templates/claude-md.d.ts.map +1 -0
- package/dist/templates/claude-md.js +74 -0
- package/dist/templates/claude-md.js.map +1 -0
- package/dist/tmux-manager.d.ts +181 -0
- package/dist/tmux-manager.d.ts.map +1 -0
- package/dist/tmux-manager.js +1405 -0
- package/dist/tmux-manager.js.map +1 -0
- package/dist/transcript-watcher.d.ts +110 -0
- package/dist/transcript-watcher.d.ts.map +1 -0
- package/dist/transcript-watcher.js +338 -0
- package/dist/transcript-watcher.js.map +1 -0
- package/dist/tunnel-manager.d.ts +54 -0
- package/dist/tunnel-manager.d.ts.map +1 -0
- package/dist/tunnel-manager.js +251 -0
- package/dist/tunnel-manager.js.map +1 -0
- package/dist/types.d.ts +1139 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +215 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/buffer-accumulator.d.ts +111 -0
- package/dist/utils/buffer-accumulator.d.ts.map +1 -0
- package/dist/utils/buffer-accumulator.js +172 -0
- package/dist/utils/buffer-accumulator.js.map +1 -0
- package/dist/utils/claude-cli-resolver.d.ts +26 -0
- package/dist/utils/claude-cli-resolver.d.ts.map +1 -0
- package/dist/utils/claude-cli-resolver.js +78 -0
- package/dist/utils/claude-cli-resolver.js.map +1 -0
- package/dist/utils/cleanup-manager.d.ts +165 -0
- package/dist/utils/cleanup-manager.d.ts.map +1 -0
- package/dist/utils/cleanup-manager.js +274 -0
- package/dist/utils/cleanup-manager.js.map +1 -0
- package/dist/utils/index.d.ts +19 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +19 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/lru-map.d.ts +140 -0
- package/dist/utils/lru-map.d.ts.map +1 -0
- package/dist/utils/lru-map.js +234 -0
- package/dist/utils/lru-map.js.map +1 -0
- package/dist/utils/nice-wrapper.d.ts +13 -0
- package/dist/utils/nice-wrapper.d.ts.map +1 -0
- package/dist/utils/nice-wrapper.js +17 -0
- package/dist/utils/nice-wrapper.js.map +1 -0
- package/dist/utils/opencode-cli-resolver.d.ts +21 -0
- package/dist/utils/opencode-cli-resolver.d.ts.map +1 -0
- package/dist/utils/opencode-cli-resolver.js +67 -0
- package/dist/utils/opencode-cli-resolver.js.map +1 -0
- package/dist/utils/regex-patterns.d.ts +64 -0
- package/dist/utils/regex-patterns.d.ts.map +1 -0
- package/dist/utils/regex-patterns.js +74 -0
- package/dist/utils/regex-patterns.js.map +1 -0
- package/dist/utils/stale-expiration-map.d.ts +159 -0
- package/dist/utils/stale-expiration-map.d.ts.map +1 -0
- package/dist/utils/stale-expiration-map.js +277 -0
- package/dist/utils/stale-expiration-map.js.map +1 -0
- package/dist/utils/string-similarity.d.ts +108 -0
- package/dist/utils/string-similarity.d.ts.map +1 -0
- package/dist/utils/string-similarity.js +189 -0
- package/dist/utils/string-similarity.js.map +1 -0
- package/dist/utils/token-validation.d.ts +39 -0
- package/dist/utils/token-validation.d.ts.map +1 -0
- package/dist/utils/token-validation.js +59 -0
- package/dist/utils/token-validation.js.map +1 -0
- package/dist/utils/type-safety.d.ts +33 -0
- package/dist/utils/type-safety.d.ts.map +1 -0
- package/dist/utils/type-safety.js +35 -0
- package/dist/utils/type-safety.js.map +1 -0
- package/dist/web/public/app.js +491 -0
- package/dist/web/public/app.js.br +0 -0
- package/dist/web/public/app.js.gz +0 -0
- package/dist/web/public/index.html +1675 -0
- package/dist/web/public/index.html.br +0 -0
- package/dist/web/public/index.html.gz +0 -0
- package/dist/web/public/manifest.json +8 -0
- package/dist/web/public/mobile.css +1 -0
- package/dist/web/public/mobile.css.br +0 -0
- package/dist/web/public/mobile.css.gz +0 -0
- package/dist/web/public/ralph-wizard.js +1037 -0
- package/dist/web/public/ralph-wizard.js.br +0 -0
- package/dist/web/public/ralph-wizard.js.gz +0 -0
- package/dist/web/public/styles.css +1 -0
- package/dist/web/public/styles.css.br +0 -0
- package/dist/web/public/styles.css.gz +0 -0
- package/dist/web/public/sw.js +67 -0
- package/dist/web/public/sw.js.br +0 -0
- package/dist/web/public/sw.js.gz +0 -0
- package/dist/web/public/upload.html +155 -0
- package/dist/web/public/upload.html.br +0 -0
- package/dist/web/public/upload.html.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js +1 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.br +0 -0
- package/dist/web/public/vendor/xterm-addon-fit.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js +1 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.br +0 -0
- package/dist/web/public/vendor/xterm-addon-unicode11.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js +2 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.br +0 -0
- package/dist/web/public/vendor/xterm-addon-webgl.min.js.gz +0 -0
- package/dist/web/public/vendor/xterm.css +209 -0
- package/dist/web/public/vendor/xterm.css.br +0 -0
- package/dist/web/public/vendor/xterm.css.gz +0 -0
- package/dist/web/public/vendor/xterm.min.js +9 -0
- package/dist/web/public/vendor/xterm.min.js.br +0 -0
- package/dist/web/public/vendor/xterm.min.js.gz +0 -0
- package/dist/web/schemas.d.ts +479 -0
- package/dist/web/schemas.d.ts.map +1 -0
- package/dist/web/schemas.js +448 -0
- package/dist/web/schemas.js.map +1 -0
- package/dist/web/server.d.ts +207 -0
- package/dist/web/server.d.ts.map +1 -0
- package/dist/web/server.js +5784 -0
- package/dist/web/server.js.map +1 -0
- package/package.json +110 -0
- package/scripts/postinstall.js +390 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview LRU (Least Recently Used) Map implementation.
|
|
3
|
+
*
|
|
4
|
+
* Extends the built-in Map with automatic eviction when a maximum size is
|
|
5
|
+
* exceeded. Uses Map's insertion-order iteration for O(1) LRU eviction.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/lru-map
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* A Map with automatic LRU (Least Recently Used) eviction.
|
|
11
|
+
*
|
|
12
|
+
* When the map exceeds maxSize, the oldest entries are evicted.
|
|
13
|
+
* Access via get() refreshes an entry's position (moves to most recent).
|
|
14
|
+
*
|
|
15
|
+
* Uses JavaScript Map's insertion-order guarantee for efficient LRU behavior.
|
|
16
|
+
* All operations are O(1) amortized.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const cache = new LRUMap<string, number>({
|
|
21
|
+
* maxSize: 100,
|
|
22
|
+
* onEvict: (key, value) => console.log(`Evicted ${key}`)
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* cache.set('a', 1);
|
|
26
|
+
* cache.set('b', 2);
|
|
27
|
+
* cache.get('a'); // Refreshes 'a', making 'b' the oldest
|
|
28
|
+
* // When full, 'b' would be evicted first
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
export class LRUMap extends Map {
|
|
32
|
+
maxSize;
|
|
33
|
+
onEvict;
|
|
34
|
+
/** Tracks the newest key for O(1) newest() access */
|
|
35
|
+
_newestKey = undefined;
|
|
36
|
+
/**
|
|
37
|
+
* Creates a new LRUMap.
|
|
38
|
+
*
|
|
39
|
+
* @param options - Configuration options
|
|
40
|
+
*/
|
|
41
|
+
constructor(options) {
|
|
42
|
+
super();
|
|
43
|
+
this.maxSize = options.maxSize;
|
|
44
|
+
this.onEvict = options.onEvict;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Set a key-value pair.
|
|
48
|
+
* If key exists, updates value and refreshes position.
|
|
49
|
+
* If adding new entry would exceed maxSize, evicts oldest entries.
|
|
50
|
+
*
|
|
51
|
+
* @param key - Key to set
|
|
52
|
+
* @param value - Value to associate
|
|
53
|
+
* @returns this (for chaining)
|
|
54
|
+
*/
|
|
55
|
+
set(key, value) {
|
|
56
|
+
// If key exists, delete first to refresh position
|
|
57
|
+
if (super.has(key)) {
|
|
58
|
+
super.delete(key);
|
|
59
|
+
}
|
|
60
|
+
// Add the entry (will be at end = most recent)
|
|
61
|
+
super.set(key, value);
|
|
62
|
+
// Track newest key for O(1) newest() access
|
|
63
|
+
this._newestKey = key;
|
|
64
|
+
// Evict oldest entries if over capacity
|
|
65
|
+
while (super.size > this.maxSize) {
|
|
66
|
+
const oldestKey = super.keys().next().value;
|
|
67
|
+
if (oldestKey !== undefined) {
|
|
68
|
+
const oldestValue = super.get(oldestKey);
|
|
69
|
+
super.delete(oldestKey);
|
|
70
|
+
this.onEvict?.(oldestKey, oldestValue);
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
return this;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Get a value and refresh its position (mark as most recently used).
|
|
77
|
+
*
|
|
78
|
+
* @param key - Key to look up
|
|
79
|
+
* @returns Value if found, undefined otherwise
|
|
80
|
+
*/
|
|
81
|
+
get(key) {
|
|
82
|
+
if (!super.has(key)) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
// Delete and re-insert to move to end (most recent)
|
|
86
|
+
const value = super.get(key);
|
|
87
|
+
super.delete(key);
|
|
88
|
+
super.set(key, value);
|
|
89
|
+
// Track newest key for O(1) newest() access
|
|
90
|
+
this._newestKey = key;
|
|
91
|
+
return value;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Check if a key exists WITHOUT refreshing its position.
|
|
95
|
+
* Use this when you want to check existence without affecting LRU order.
|
|
96
|
+
*
|
|
97
|
+
* @param key - Key to check
|
|
98
|
+
* @returns True if key exists
|
|
99
|
+
*/
|
|
100
|
+
has(key) {
|
|
101
|
+
return super.has(key);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Delete a key-value pair.
|
|
105
|
+
* Updates _newestKey if the deleted key was the newest.
|
|
106
|
+
*
|
|
107
|
+
* @param key - Key to delete
|
|
108
|
+
* @returns True if the key existed and was deleted
|
|
109
|
+
*/
|
|
110
|
+
delete(key) {
|
|
111
|
+
const existed = super.delete(key);
|
|
112
|
+
// If we deleted the newest key, we need to find the new newest
|
|
113
|
+
// This is O(n) but delete is rare; set/get are the hot paths
|
|
114
|
+
if (existed && this._newestKey === key) {
|
|
115
|
+
this._newestKey = undefined;
|
|
116
|
+
// Find the new newest by iterating (last entry)
|
|
117
|
+
for (const k of super.keys()) {
|
|
118
|
+
this._newestKey = k;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return existed;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Clear all entries.
|
|
125
|
+
* Resets _newestKey to undefined.
|
|
126
|
+
*/
|
|
127
|
+
clear() {
|
|
128
|
+
super.clear();
|
|
129
|
+
this._newestKey = undefined;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Peek at a value WITHOUT refreshing its position.
|
|
133
|
+
* Use this when you want to read without affecting LRU order.
|
|
134
|
+
*
|
|
135
|
+
* @param key - Key to peek
|
|
136
|
+
* @returns Value if found, undefined otherwise
|
|
137
|
+
*/
|
|
138
|
+
peek(key) {
|
|
139
|
+
return super.get(key);
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Get the oldest entry (next to be evicted) without removing it.
|
|
143
|
+
*
|
|
144
|
+
* @returns [key, value] of oldest entry, or undefined if empty
|
|
145
|
+
*/
|
|
146
|
+
oldest() {
|
|
147
|
+
const first = super.entries().next();
|
|
148
|
+
if (first.done)
|
|
149
|
+
return undefined;
|
|
150
|
+
return first.value;
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Get the newest entry (most recently accessed).
|
|
154
|
+
* O(1) operation using tracked newest key.
|
|
155
|
+
*
|
|
156
|
+
* @returns [key, value] of newest entry, or undefined if empty
|
|
157
|
+
*/
|
|
158
|
+
newest() {
|
|
159
|
+
if (this._newestKey === undefined || !super.has(this._newestKey)) {
|
|
160
|
+
return undefined;
|
|
161
|
+
}
|
|
162
|
+
// Use super.get to avoid refreshing the position
|
|
163
|
+
const value = super.get(this._newestKey);
|
|
164
|
+
return [this._newestKey, value];
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Evict entries older than a specific timestamp.
|
|
168
|
+
* Assumes values have a timestamp property or are numbers representing time.
|
|
169
|
+
*
|
|
170
|
+
* @param maxAge - Maximum age in milliseconds
|
|
171
|
+
* @param getTimestamp - Function to extract timestamp from value
|
|
172
|
+
* @returns Number of entries evicted
|
|
173
|
+
*/
|
|
174
|
+
expireOlderThan(maxAge, getTimestamp) {
|
|
175
|
+
const now = Date.now();
|
|
176
|
+
const cutoff = now - maxAge;
|
|
177
|
+
let evicted = 0;
|
|
178
|
+
let deletedNewest = false;
|
|
179
|
+
// Iterate from oldest to newest
|
|
180
|
+
for (const [key, value] of super.entries()) {
|
|
181
|
+
if (getTimestamp(value) < cutoff) {
|
|
182
|
+
// Track if we're deleting the newest key
|
|
183
|
+
if (key === this._newestKey) {
|
|
184
|
+
deletedNewest = true;
|
|
185
|
+
}
|
|
186
|
+
super.delete(key);
|
|
187
|
+
this.onEvict?.(key, value);
|
|
188
|
+
evicted++;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
// Since entries are ordered, once we find a non-expired one,
|
|
192
|
+
// all subsequent entries are also non-expired
|
|
193
|
+
break;
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
// Update _newestKey if we deleted it (find new newest from remaining entries)
|
|
197
|
+
if (deletedNewest) {
|
|
198
|
+
this._newestKey = undefined;
|
|
199
|
+
for (const k of super.keys()) {
|
|
200
|
+
this._newestKey = k; // Last one becomes newest
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return evicted;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get all keys in order from oldest to newest.
|
|
207
|
+
*
|
|
208
|
+
* @returns Array of keys
|
|
209
|
+
*/
|
|
210
|
+
keysInOrder() {
|
|
211
|
+
return Array.from(super.keys());
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Get all values in order from oldest to newest.
|
|
215
|
+
*
|
|
216
|
+
* @returns Array of values
|
|
217
|
+
*/
|
|
218
|
+
valuesInOrder() {
|
|
219
|
+
return Array.from(super.values());
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Get the maximum size limit.
|
|
223
|
+
*/
|
|
224
|
+
get maxEntries() {
|
|
225
|
+
return this.maxSize;
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Get the number of free slots before eviction would occur.
|
|
229
|
+
*/
|
|
230
|
+
get freeSlots() {
|
|
231
|
+
return Math.max(0, this.maxSize - super.size);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
//# sourceMappingURL=lru-map.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lru-map.js","sourceRoot":"","sources":["../../src/utils/lru-map.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAYH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,MAAM,OAAO,MAAa,SAAQ,GAAS;IACxB,OAAO,CAAS;IAChB,OAAO,CAA8B;IACtD,qDAAqD;IAC7C,UAAU,GAAkB,SAAS,CAAC;IAE9C;;;;OAIG;IACH,YAAY,OAA4B;QACtC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;QAC/B,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC;IACjC,CAAC;IAED;;;;;;;;OAQG;IACM,GAAG,CAAC,GAAM,EAAE,KAAQ;QAC3B,kDAAkD;QAClD,IAAI,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,EAAE,CAAC;YACnB,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;QAED,+CAA+C;QAC/C,KAAK,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;QACtB,4CAA4C;QAC5C,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QAEtB,wCAAwC;QACxC,OAAO,KAAK,CAAC,IAAI,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;Y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,CAAC;oBAC5B,aAAa,GAAG,IAAI,CAAC;gBACvB,CAAC;gBACD,KAAK,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;gBAClB,IAAI,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBAC3B,OAAO,EAAE,CAAC;YACZ,CAAC;iBAAM,CAAC;gBACN,6DAA6D;gBAC7D,8CAA8C;gBAC9C,MAAM;YACR,CAAC;QACH,CAAC;QAED,8EAA8E;QAC9E,IAAI,aAAa,EAAE,CAAC;YAClB,IAAI,CAAC,UAAU,GAAG,SAAS,CAAC;YAC5B,KAAK,MAAM,CAAC,IAAI,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;gBAC7B,IAAI,CAAC,UAAU,GAAG,CAAC,CAAC,CAAC,0BAA0B;YACjD,CAAC;QACH,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACH,WAAW;QACT,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC,CAAC;IAClC,CAAC;IAED;;;;OAIG;IACH,aAAa;QACX,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,IAAI,UAAU;QACZ,OAAO,IAAI,CAAC,OAAO,CAAC;IACtB,CAAC;IAED;;OAEG;IACH,IAAI,SAAS;QACX,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;IAChD,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shared utility for wrapping commands with `nice` priority.
|
|
3
|
+
*
|
|
4
|
+
* Extracted as a shared utility for tmux-manager and other consumers.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/nice-wrapper
|
|
7
|
+
*/
|
|
8
|
+
import type { NiceConfig } from '../types.js';
|
|
9
|
+
/**
|
|
10
|
+
* Wraps a command with `nice` for priority adjustment.
|
|
11
|
+
*/
|
|
12
|
+
export declare function wrapWithNice(cmd: string, config: NiceConfig): string;
|
|
13
|
+
//# sourceMappingURL=nice-wrapper.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nice-wrapper.d.ts","sourceRoot":"","sources":["../../src/utils/nice-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAIpE"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shared utility for wrapping commands with `nice` priority.
|
|
3
|
+
*
|
|
4
|
+
* Extracted as a shared utility for tmux-manager and other consumers.
|
|
5
|
+
*
|
|
6
|
+
* @module utils/nice-wrapper
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* Wraps a command with `nice` for priority adjustment.
|
|
10
|
+
*/
|
|
11
|
+
export function wrapWithNice(cmd, config) {
|
|
12
|
+
if (!config.enabled)
|
|
13
|
+
return cmd;
|
|
14
|
+
const niceValue = Math.max(-20, Math.min(19, config.niceValue));
|
|
15
|
+
return `nice -n ${niceValue} ${cmd}`;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=nice-wrapper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nice-wrapper.js","sourceRoot":"","sources":["../../src/utils/nice-wrapper.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH;;GAEG;AACH,MAAM,UAAU,YAAY,CAAC,GAAW,EAAE,MAAkB;IAC1D,IAAI,CAAC,MAAM,CAAC,OAAO;QAAE,OAAO,GAAG,CAAC;IAChC,MAAM,SAAS,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC;IAChE,OAAO,WAAW,SAAS,IAAI,GAAG,EAAE,CAAC;AACvC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Resolve the OpenCode CLI binary across common install paths.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors claude-cli-resolver.ts pattern. Finds the `opencode` binary
|
|
5
|
+
* and provides an augmented PATH string for tmux sessions.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/opencode-cli-resolver
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Finds the directory containing the `opencode` binary.
|
|
11
|
+
* Checks `which opencode` first, then falls back to common install locations.
|
|
12
|
+
* Result is cached for subsequent calls.
|
|
13
|
+
*
|
|
14
|
+
* @returns Directory path, or null if not found
|
|
15
|
+
*/
|
|
16
|
+
export declare function resolveOpenCodeDir(): string | null;
|
|
17
|
+
/**
|
|
18
|
+
* Check if OpenCode CLI is available on the system.
|
|
19
|
+
*/
|
|
20
|
+
export declare function isOpenCodeAvailable(): boolean;
|
|
21
|
+
//# sourceMappingURL=opencode-cli-resolver.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-cli-resolver.d.ts","sourceRoot":"","sources":["../../src/utils/opencode-cli-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAwBH;;;;;;GAMG;AACH,wBAAgB,kBAAkB,IAAI,MAAM,GAAG,IAAI,CA2BlD;AAED;;GAEG;AACH,wBAAgB,mBAAmB,IAAI,OAAO,CAE7C"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Resolve the OpenCode CLI binary across common install paths.
|
|
3
|
+
*
|
|
4
|
+
* Mirrors claude-cli-resolver.ts pattern. Finds the `opencode` binary
|
|
5
|
+
* and provides an augmented PATH string for tmux sessions.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/opencode-cli-resolver
|
|
8
|
+
*/
|
|
9
|
+
import { execSync } from 'node:child_process';
|
|
10
|
+
import { existsSync } from 'node:fs';
|
|
11
|
+
import { dirname, join } from 'node:path';
|
|
12
|
+
import { homedir } from 'node:os';
|
|
13
|
+
/** Timeout for exec commands (5 seconds) */
|
|
14
|
+
const EXEC_TIMEOUT_MS = 5000;
|
|
15
|
+
/** Common directories where the OpenCode CLI binary may be installed */
|
|
16
|
+
const OPENCODE_SEARCH_DIRS = [
|
|
17
|
+
join(homedir(), '.opencode', 'bin'), // Default install location
|
|
18
|
+
join(homedir(), '.local', 'bin'), // Alternative install location
|
|
19
|
+
'/usr/local/bin', // Homebrew / system
|
|
20
|
+
join(homedir(), 'go', 'bin'), // Go install
|
|
21
|
+
join(homedir(), '.bun', 'bin'), // Bun global
|
|
22
|
+
join(homedir(), '.npm-global', 'bin'), // npm global
|
|
23
|
+
join(homedir(), 'bin'), // User bin
|
|
24
|
+
];
|
|
25
|
+
/** Cached directory containing the opencode binary (empty string = searched but not found) */
|
|
26
|
+
let _openCodeDir = null;
|
|
27
|
+
/**
|
|
28
|
+
* Finds the directory containing the `opencode` binary.
|
|
29
|
+
* Checks `which opencode` first, then falls back to common install locations.
|
|
30
|
+
* Result is cached for subsequent calls.
|
|
31
|
+
*
|
|
32
|
+
* @returns Directory path, or null if not found
|
|
33
|
+
*/
|
|
34
|
+
export function resolveOpenCodeDir() {
|
|
35
|
+
if (_openCodeDir !== null)
|
|
36
|
+
return _openCodeDir || null;
|
|
37
|
+
// Try `which` first (respects current PATH)
|
|
38
|
+
try {
|
|
39
|
+
const result = execSync('which opencode', {
|
|
40
|
+
encoding: 'utf-8',
|
|
41
|
+
timeout: EXEC_TIMEOUT_MS,
|
|
42
|
+
}).trim();
|
|
43
|
+
if (result && existsSync(result)) {
|
|
44
|
+
_openCodeDir = dirname(result);
|
|
45
|
+
return _openCodeDir;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
catch {
|
|
49
|
+
// OpenCode not in PATH, will check common locations
|
|
50
|
+
}
|
|
51
|
+
// Fallback: check common installation directories
|
|
52
|
+
for (const dir of OPENCODE_SEARCH_DIRS) {
|
|
53
|
+
if (existsSync(join(dir, 'opencode'))) {
|
|
54
|
+
_openCodeDir = dir;
|
|
55
|
+
return _openCodeDir;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
_openCodeDir = ''; // mark as searched, not found
|
|
59
|
+
return null;
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Check if OpenCode CLI is available on the system.
|
|
63
|
+
*/
|
|
64
|
+
export function isOpenCodeAvailable() {
|
|
65
|
+
return resolveOpenCodeDir() !== null;
|
|
66
|
+
}
|
|
67
|
+
//# sourceMappingURL=opencode-cli-resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"opencode-cli-resolver.js","sourceRoot":"","sources":["../../src/utils/opencode-cli-resolver.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAElC,4CAA4C;AAC5C,MAAM,eAAe,GAAG,IAAI,CAAC;AAE7B,wEAAwE;AACxE,MAAM,oBAAoB,GAAG;IAC3B,IAAI,CAAC,OAAO,EAAE,EAAE,WAAW,EAAE,KAAK,CAAC,EAAE,2BAA2B;IAChE,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,EAAE,+BAA+B;IACjE,gBAAgB,EAAE,oBAAoB;IACtC,IAAI,CAAC,OAAO,EAAE,EAAE,IAAI,EAAE,KAAK,CAAC,EAAE,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sing.
|
|
3
|
+
*
|
|
4
|
+
* Pre-compiled patterns avoid re-compilation overhead on each use.
|
|
5
|
+
* Import these patterns instead of defining them locally.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/regex-patterns
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Comprehensive ANSI escape pattern that handles:
|
|
11
|
+
* - SGR (colors/styles): ESC [ params m
|
|
12
|
+
* - CSI sequences (cursor, scroll, etc.): ESC [ params letter
|
|
13
|
+
* - OSC sequences (title, etc.): ESC ] ... BEL or ESC ] ... ST
|
|
14
|
+
* - Single-char escapes: ESC = or ESC >
|
|
15
|
+
*
|
|
16
|
+
* Use this when you need complete ANSI stripping including OSC sequences.
|
|
17
|
+
* Note: Has global flag - reset lastIndex before exec() if reusing.
|
|
18
|
+
*/
|
|
19
|
+
export declare const ANSI_ESCAPE_PATTERN_FULL: RegExp;
|
|
20
|
+
/**
|
|
21
|
+
* Simple ANSI CSI-only pattern for basic escape code stripping.
|
|
22
|
+
* Matches: ESC [ params letter (e.g., colors, cursor movement)
|
|
23
|
+
*
|
|
24
|
+
* Use this for faster stripping when OSC sequences aren't a concern.
|
|
25
|
+
* Note: Has global flag - reset lastIndex before exec() if reusing.
|
|
26
|
+
*/
|
|
27
|
+
export declare const ANSI_ESCAPE_PATTERN_SIMPLE: RegExp;
|
|
28
|
+
/**
|
|
29
|
+
* Pattern to extract token count from Claude's status line.
|
|
30
|
+
* Matches: "123.4k tokens", "5234 tokens", "1.2M tokens"
|
|
31
|
+
*
|
|
32
|
+
* Capture groups:
|
|
33
|
+
* - Group 1: The numeric value (e.g., "123.4", "5234", "1.2")
|
|
34
|
+
* - Group 2: Optional suffix (k, K, m, M) or undefined
|
|
35
|
+
*/
|
|
36
|
+
export declare const TOKEN_PATTERN: RegExp;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a fresh copy of ANSI_ESCAPE_PATTERN_FULL.
|
|
39
|
+
* Use when you need a pattern without shared lastIndex state.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createAnsiPatternFull(): RegExp;
|
|
42
|
+
/**
|
|
43
|
+
* Creates a fresh copy of ANSI_ESCAPE_PATTERN_SIMPLE.
|
|
44
|
+
* Use when you need a pattern without shared lastIndex state.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createAnsiPatternSimple(): RegExp;
|
|
47
|
+
/**
|
|
48
|
+
* Strips ANSI escape codes from text using the comprehensive pattern.
|
|
49
|
+
* @param text - Text containing ANSI escape codes
|
|
50
|
+
* @returns Text with ANSI codes removed
|
|
51
|
+
*/
|
|
52
|
+
export declare function stripAnsi(text: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Regex to validate safe file paths (no shell metacharacters).
|
|
55
|
+
* Shared by schemas.ts and tmux-manager.ts for consistent path validation.
|
|
56
|
+
*/
|
|
57
|
+
/**
|
|
58
|
+
* Braille spinner characters used by Claude Code's Ink UI.
|
|
59
|
+
* Matches any of: ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧
|
|
60
|
+
* Used on the hot path (every PTY chunk) — pre-compiled for performance.
|
|
61
|
+
*/
|
|
62
|
+
export declare const SPINNER_PATTERN: RegExp;
|
|
63
|
+
export declare const SAFE_PATH_PATTERN: RegExp;
|
|
64
|
+
//# sourceMappingURL=regex-patterns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex-patterns.d.ts","sourceRoot":"","sources":["../../src/utils/regex-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AAEH,eAAO,MAAM,wBAAwB,QAAmE,CAAC;AAEzG;;;;;;GAMG;AAEH,eAAO,MAAM,0BAA0B,QAA2B,CAAC;AAEnE;;;;;;;GAOG;AACH,eAAO,MAAM,aAAa,QAAyC,CAAC;AAEpE;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,MAAM,CAG9C;AAED;;;GAGG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAGhD;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAE9C;AAED;;;GAGG;AACH;;;;GAIG;AACH,eAAO,MAAM,eAAe,QAAe,CAAC;AAE5C,eAAO,MAAM,iBAAiB,QAA0B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @fileoverview Shared regex patterns for terminal and token parsing.
|
|
3
|
+
*
|
|
4
|
+
* Pre-compiled patterns avoid re-compilation overhead on each use.
|
|
5
|
+
* Import these patterns instead of defining them locally.
|
|
6
|
+
*
|
|
7
|
+
* @module utils/regex-patterns
|
|
8
|
+
*/
|
|
9
|
+
/**
|
|
10
|
+
* Comprehensive ANSI escape pattern that handles:
|
|
11
|
+
* - SGR (colors/styles): ESC [ params m
|
|
12
|
+
* - CSI sequences (cursor, scroll, etc.): ESC [ params letter
|
|
13
|
+
* - OSC sequences (title, etc.): ESC ] ... BEL or ESC ] ... ST
|
|
14
|
+
* - Single-char escapes: ESC = or ESC >
|
|
15
|
+
*
|
|
16
|
+
* Use this when you need complete ANSI stripping including OSC sequences.
|
|
17
|
+
* Note: Has global flag - reset lastIndex before exec() if reusing.
|
|
18
|
+
*/
|
|
19
|
+
// eslint-disable-next-line no-control-regex
|
|
20
|
+
export const ANSI_ESCAPE_PATTERN_FULL = /\x1b(?:\[[0-9;?]*[A-Za-z]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[=>])/g;
|
|
21
|
+
/**
|
|
22
|
+
* Simple ANSI CSI-only pattern for basic escape code stripping.
|
|
23
|
+
* Matches: ESC [ params letter (e.g., colors, cursor movement)
|
|
24
|
+
*
|
|
25
|
+
* Use this for faster stripping when OSC sequences aren't a concern.
|
|
26
|
+
* Note: Has global flag - reset lastIndex before exec() if reusing.
|
|
27
|
+
*/
|
|
28
|
+
// eslint-disable-next-line no-control-regex
|
|
29
|
+
export const ANSI_ESCAPE_PATTERN_SIMPLE = /\x1b\[[0-9;]*[A-Za-z]/g;
|
|
30
|
+
/**
|
|
31
|
+
* Pattern to extract token count from Claude's status line.
|
|
32
|
+
* Matches: "123.4k tokens", "5234 tokens", "1.2M tokens"
|
|
33
|
+
*
|
|
34
|
+
* Capture groups:
|
|
35
|
+
* - Group 1: The numeric value (e.g., "123.4", "5234", "1.2")
|
|
36
|
+
* - Group 2: Optional suffix (k, K, m, M) or undefined
|
|
37
|
+
*/
|
|
38
|
+
export const TOKEN_PATTERN = /(\d+(?:\.\d+)?)\s*([kKmM])?\s*tokens/;
|
|
39
|
+
/**
|
|
40
|
+
* Creates a fresh copy of ANSI_ESCAPE_PATTERN_FULL.
|
|
41
|
+
* Use when you need a pattern without shared lastIndex state.
|
|
42
|
+
*/
|
|
43
|
+
export function createAnsiPatternFull() {
|
|
44
|
+
// eslint-disable-next-line no-control-regex
|
|
45
|
+
return /\x1b(?:\[[0-9;?]*[A-Za-z]|\][^\x07\x1b]*(?:\x07|\x1b\\)|[=>])/g;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a fresh copy of ANSI_ESCAPE_PATTERN_SIMPLE.
|
|
49
|
+
* Use when you need a pattern without shared lastIndex state.
|
|
50
|
+
*/
|
|
51
|
+
export function createAnsiPatternSimple() {
|
|
52
|
+
// eslint-disable-next-line no-control-regex
|
|
53
|
+
return /\x1b\[[0-9;]*[A-Za-z]/g;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Strips ANSI escape codes from text using the comprehensive pattern.
|
|
57
|
+
* @param text - Text containing ANSI escape codes
|
|
58
|
+
* @returns Text with ANSI codes removed
|
|
59
|
+
*/
|
|
60
|
+
export function stripAnsi(text) {
|
|
61
|
+
return text.replace(ANSI_ESCAPE_PATTERN_FULL, '');
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Regex to validate safe file paths (no shell metacharacters).
|
|
65
|
+
* Shared by schemas.ts and tmux-manager.ts for consistent path validation.
|
|
66
|
+
*/
|
|
67
|
+
/**
|
|
68
|
+
* Braille spinner characters used by Claude Code's Ink UI.
|
|
69
|
+
* Matches any of: ⠋ ⠙ ⠹ ⠸ ⠼ ⠴ ⠦ ⠧
|
|
70
|
+
* Used on the hot path (every PTY chunk) — pre-compiled for performance.
|
|
71
|
+
*/
|
|
72
|
+
export const SPINNER_PATTERN = /[⠋⠙⠹⠸⠼⠴⠦⠧]/;
|
|
73
|
+
export const SAFE_PATH_PATTERN = /^[a-zA-Z0-9_/\-. ~]+$/;
|
|
74
|
+
//# sourceMappingURL=regex-patterns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"regex-patterns.js","sourceRoot":"","sources":["../../src/utils/regex-patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH;;;;;;;;;GASG;AACH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,wBAAwB,GAAG,gEAAgE,CAAC;AAEzG;;;;;;GAMG;AACH,4CAA4C;AAC5C,MAAM,CAAC,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAEnE;;;;;;;GAOG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,sCAAsC,CAAC;AAEpE;;;GAGG;AACH,MAAM,UAAU,qBAAqB;IACnC,4CAA4C;IAC5C,OAAO,gEAAgE,CAAC;AAC1E,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB;IACrC,4CAA4C;IAC5C,OAAO,wBAAwB,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,SAAS,CAAC,IAAY;IACpC,OAAO,IAAI,CAAC,OAAO,CAAC,wBAAwB,EAAE,EAAE,CAAC,CAAC;AACpD,CAAC;AAED;;;GAGG;AACH;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAE5C,MAAM,CAAC,MAAM,iBAAiB,GAAG,uBAAuB,CAAC"}
|