@pageai/ralph-loop 1.13.0 → 1.14.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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # A Ralph Wiggum Loop implementation that works™
2
2
 
3
+ [![@pageai/ralph-loop version](https://img.shields.io/npm/v/@pageai/ralph-loop?label=npm&style=flat)](https://github.com/pageai-pro/ralph-loop)
4
+
3
5
  Ralph is a long-running AI agent loop. Ralph automates software development tasks by iteratively working through a task list until completion. This allows for long running agent loops, effectively enabling AI to code for days at a time.
4
6
 
5
7
  This is an implementation that actually works, containing a hackable script so you can configure it to your env and favorite agentic AI CLI. It's set up by default to use Claude Code in a Docker sandbox, but supports [many other agentic AI CLIs](#running-with-a-different-agentic-cli).
@@ -42,7 +44,7 @@ This is an implementation that actually works, containing a hackable script so y
42
44
  I recommend using a CLI to bootstrap your project with the necessary tools and dependencies, e.g.:
43
45
 
44
46
  ```bash
45
- npx @tanstack/cli create lib --add-ons shadcn,eslint,form,tanstack-query,nitro --no-git
47
+ npx @tanstack/cli create lib --add-ons eslint,form,tanstack-query,nitro --no-git
46
48
  ```
47
49
 
48
50
  > If you must start from a blank slate, which is not recommended, see [Starting from scratch](#starting-from-scratch). You can also go for a more barebone start by running `npx create-vite@latest src --template react-ts`
package/bin/lib/shadcn.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * shadcn/ui module for Ralph Loop CLI
3
- * Detects shadcn config and installs all components
3
+ * Detects React projects, initializes shadcn if needed, and installs all components
4
4
  */
5
5
 
6
6
  const fs = require('fs');
@@ -15,7 +15,7 @@ const SHADCN_SCHEMA = 'https://ui.shadcn.com/schema.json';
15
15
  * @param {string} dir - Directory path to check
16
16
  * @returns {boolean}
17
17
  */
18
- function isShadcnProject(dir) {
18
+ function hasShadcnConfig(dir) {
19
19
  const configPath = path.join(dir, 'components.json');
20
20
  if (!exists(configPath)) return false;
21
21
 
@@ -28,10 +28,55 @@ function isShadcnProject(dir) {
28
28
  }
29
29
 
30
30
  /**
31
- * Installs all shadcn/ui components in the given directory
31
+ * Checks if a directory is a React project by looking for react in package.json
32
+ * @param {string} dir - Directory path to check
33
+ * @returns {boolean}
34
+ */
35
+ function isReactProject(dir) {
36
+ const pkgPath = path.join(dir, 'package.json');
37
+ if (!exists(pkgPath)) return false;
38
+
39
+ try {
40
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'));
41
+ const allDeps = { ...pkg.dependencies, ...pkg.devDependencies };
42
+ return 'react' in allDeps;
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+
48
+ /**
49
+ * Returns true if shadcn components should be installed.
50
+ * Either the project already has a shadcn config, or it's a React project
51
+ * where we can init shadcn first.
52
+ * @param {string} dir - Directory path to check
53
+ * @returns {boolean}
54
+ */
55
+ function isShadcnProject(dir) {
56
+ return hasShadcnConfig(dir) || isReactProject(dir);
57
+ }
58
+
59
+ /**
60
+ * Initializes shadcn in the given directory with default settings.
61
+ * @param {string} dir - Directory path to run the init in
62
+ */
63
+ function initShadcn(dir) {
64
+ execSync('npx shadcn@latest init -y -d 2>&1', {
65
+ cwd: dir,
66
+ stdio: 'pipe',
67
+ });
68
+ }
69
+
70
+ /**
71
+ * Installs all shadcn/ui components in the given directory.
72
+ * Runs init first if no components.json exists.
32
73
  * @param {string} dir - Directory path to run the install in
33
74
  */
34
75
  function installAllComponents(dir) {
76
+ if (!hasShadcnConfig(dir)) {
77
+ initShadcn(dir);
78
+ }
79
+
35
80
  execSync('npx shadcn@latest add --all --yes --overwrite 2>&1', {
36
81
  cwd: dir,
37
82
  stdio: 'pipe',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pageai/ralph-loop",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },