@itsautomata/prism 0.3.1 → 0.3.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/README.md CHANGED
@@ -17,7 +17,8 @@ https://github.com/user-attachments/assets/3451a4ec-1a4f-431d-bd15-aba799b9cdf4
17
17
  requires Node.js 20+.
18
18
 
19
19
  ```bash
20
- npm install -g @itsautomata/prism
20
+ npm install -g @itsautomata/prism # install
21
+ npm install -g @itsautomata/prism@latest # upgrade to the latest release
21
22
  prism
22
23
  ```
23
24
 
@@ -107,7 +108,7 @@ sessions saved at `~/.prism/sessions/`.
107
108
 
108
109
  ## permissions
109
110
 
110
- write operations ask before executing. read operations auto-allow. by default, subagents are read-only. user-defined agents can declare `permissions: inherit` to write through the parent's permission prompt.
111
+ write operations ask before executing. reads inside the project auto-allow; reads outside the project tree (home dotfiles, `~/.ssh`, secrets like `.env`) ask first. by default, subagents are read-only. user-defined agents can declare `permissions: inherit` to write through the parent's permission prompt.
111
112
 
112
113
  ```
113
114
  ◆ Bash wants to: run: git push
package/dist/cli.js CHANGED
@@ -1930,9 +1930,12 @@ var PromptInput = memo(function PromptInput2({ onSubmit, isLoading, inPlanMode,
1930
1930
  const scheduleDisplayUpdate = useCallback(() => {
1931
1931
  if (timerRef.current) return;
1932
1932
  timerRef.current = setTimeout(() => {
1933
- setDisplayBuf(bufferRef.current);
1934
- setCursorPos(cursorRef.current);
1935
- timerRef.current = null;
1933
+ try {
1934
+ setDisplayBuf(bufferRef.current);
1935
+ setCursorPos(cursorRef.current);
1936
+ } finally {
1937
+ timerRef.current = null;
1938
+ }
1936
1939
  }, 16);
1937
1940
  }, []);
1938
1941
  useEffect(() => {
@@ -2072,7 +2075,6 @@ var PromptInput = memo(function PromptInput2({ onSubmit, isLoading, inPlanMode,
2072
2075
  if (escapeTimerRef.current && !key.escape) {
2073
2076
  clearTimeout(escapeTimerRef.current);
2074
2077
  escapeTimerRef.current = null;
2075
- clearBufferNow();
2076
2078
  }
2077
2079
  if (matches.length > 0) {
2078
2080
  if (key.upArrow) {
@@ -2168,7 +2170,6 @@ var PromptInput = memo(function PromptInput2({ onSubmit, isLoading, inPlanMode,
2168
2170
  if (key.escape) {
2169
2171
  if (escapeTimerRef.current) clearTimeout(escapeTimerRef.current);
2170
2172
  escapeTimerRef.current = setTimeout(() => {
2171
- clearBufferNow();
2172
2173
  escapeTimerRef.current = null;
2173
2174
  }, 50);
2174
2175
  return;
@@ -4012,53 +4013,64 @@ function detectEntryPoint(cwd, language) {
4012
4013
  return null;
4013
4014
  }
4014
4015
  function detectStructure(cwd) {
4015
- const filesByType = {};
4016
- const directories = [];
4017
4016
  const configFiles = [];
4018
- let totalFiles = 0;
4019
4017
  for (const cf of CONFIG_FILES) {
4020
4018
  if (existsSync7(join7(cwd, cf))) configFiles.push(cf);
4021
4019
  }
4022
- try {
4023
- for (const entry of readdirSync4(cwd)) {
4024
- const path = join7(cwd, entry);
4025
- try {
4026
- const stat = statSync(path);
4027
- if (stat.isDirectory() && !entry.startsWith(".") && !IGNORE_DIRS.has(entry)) {
4028
- directories.push(entry);
4029
- }
4030
- } catch {
4031
- }
4032
- }
4033
- } catch {
4034
- }
4035
- countFiles(cwd, filesByType, 0, 2);
4020
+ const { filesByType, directories } = scanTree(cwd, 2, { remaining: SCAN_STAT_BUDGET });
4021
+ let totalFiles = 0;
4036
4022
  for (const count of Object.values(filesByType)) {
4037
4023
  totalFiles += count;
4038
4024
  }
4039
4025
  return { totalFiles, filesByType, directories, configFiles };
4040
4026
  }
4041
- function countFiles(dir, counts, depth, maxDepth) {
4042
- if (depth > maxDepth) return;
4043
- try {
4044
- for (const entry of readdirSync4(dir)) {
4045
- if (IGNORE_DIRS.has(entry) || entry.startsWith(".")) continue;
4046
- const path = join7(dir, entry);
4047
- try {
4048
- const stat = statSync(path);
4049
- if (stat.isFile()) {
4050
- const ext = extname(entry);
4051
- if (ext) {
4052
- counts[ext] = (counts[ext] || 0) + 1;
4053
- }
4054
- } else if (stat.isDirectory()) {
4055
- countFiles(path, counts, depth + 1, maxDepth);
4027
+ var SCAN_STAT_BUDGET = 4e3;
4028
+ var SCAN_DIR_STRIDE = 256;
4029
+ function scanTree(root, maxDepth, budget) {
4030
+ const filesByType = {};
4031
+ const directories = [];
4032
+ const queue = [];
4033
+ const enqueue = (dir, depth) => {
4034
+ try {
4035
+ queue.push({ dir, depth, entries: readdirSync4(dir, { withFileTypes: true }), idx: 0 });
4036
+ } catch {
4037
+ }
4038
+ };
4039
+ enqueue(root, 0);
4040
+ while (queue.length > 0 && budget.remaining > 0) {
4041
+ const frame = queue.shift();
4042
+ let taken = 0;
4043
+ while (frame.idx < frame.entries.length && taken < SCAN_DIR_STRIDE && budget.remaining > 0) {
4044
+ const ent = frame.entries[frame.idx++];
4045
+ const name = ent.name;
4046
+ if (IGNORE_DIRS.has(name) || name.startsWith(".")) continue;
4047
+ taken++;
4048
+ budget.remaining--;
4049
+ const isLink = ent.isSymbolicLink();
4050
+ let isDir = ent.isDirectory();
4051
+ let isFile = ent.isFile();
4052
+ if (isLink) {
4053
+ try {
4054
+ const s = statSync(join7(frame.dir, name));
4055
+ isDir = s.isDirectory();
4056
+ isFile = s.isFile();
4057
+ } catch {
4058
+ continue;
4059
+ }
4060
+ }
4061
+ if (isDir) {
4062
+ if (frame.depth === 0) directories.push(name);
4063
+ if (!isLink && frame.depth < maxDepth) enqueue(join7(frame.dir, name), frame.depth + 1);
4064
+ } else if (isFile) {
4065
+ const ext = extname(name);
4066
+ if (ext) {
4067
+ filesByType[ext] = (filesByType[ext] || 0) + 1;
4056
4068
  }
4057
- } catch {
4058
4069
  }
4059
4070
  }
4060
- } catch {
4071
+ if (frame.idx < frame.entries.length) queue.push(frame);
4061
4072
  }
4073
+ return { filesByType, directories };
4062
4074
  }
4063
4075
  function detectGit(cwd) {
4064
4076
  if (!existsSync7(join7(cwd, ".git"))) return null;
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "name": "@itsautomata/prism",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "lockfileVersion": 3,
5
5
  "requires": true,
6
6
  "packages": {
7
7
  "": {
8
8
  "name": "@itsautomata/prism",
9
- "version": "0.3.1",
9
+ "version": "0.3.3",
10
10
  "license": "MIT",
11
11
  "dependencies": {
12
12
  "cheerio": "^1.2.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itsautomata/prism",
3
- "version": "0.3.1",
3
+ "version": "0.3.3",
4
4
  "description": "local-first AI coding assistant, runs against ollama or openrouter",
5
5
  "type": "module",
6
6
  "license": "MIT",