@prmichaelsen/acp-visualizer 0.2.1 → 0.5.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.
@@ -0,0 +1,69 @@
1
+ import { createServerFn } from '@tanstack/react-start'
2
+
3
+ export interface AcpProject {
4
+ id: string
5
+ path: string
6
+ type: string
7
+ description: string
8
+ status: string
9
+ hasProgress: boolean
10
+ }
11
+
12
+ export const listProjects = createServerFn({ method: 'GET' }).handler(
13
+ async (): Promise<AcpProject[]> => {
14
+ try {
15
+ const { readFileSync, existsSync } = await import('fs')
16
+ const { resolve } = await import('path')
17
+ const { homedir } = await import('os')
18
+ const yaml = await import('js-yaml')
19
+
20
+ const projectsFile = resolve(homedir(), '.acp', 'projects.yaml')
21
+ if (!existsSync(projectsFile)) return []
22
+
23
+ const raw = readFileSync(projectsFile, 'utf-8')
24
+ const doc = yaml.load(raw, { json: true }) as Record<string, unknown>
25
+ const projects = (doc?.projects || {}) as Record<string, Record<string, unknown>>
26
+
27
+ return Object.entries(projects).map(([id, p]) => {
28
+ const projectPath = String(p.path || '')
29
+ const progressPath = resolve(projectPath, 'agent', 'progress.yaml')
30
+ return {
31
+ id,
32
+ path: projectPath,
33
+ type: String(p.type || 'unknown'),
34
+ description: String(p.description || ''),
35
+ status: String(p.status || 'unknown'),
36
+ hasProgress: existsSync(progressPath),
37
+ }
38
+ })
39
+ } catch {
40
+ // Cloudflare Workers: no filesystem
41
+ return []
42
+ }
43
+ },
44
+ )
45
+
46
+ export const getProjectProgressPath = createServerFn({ method: 'GET' })
47
+ .validator((input: { projectId: string }) => input)
48
+ .handler(async ({ data }): Promise<string | null> => {
49
+ try {
50
+ const { readFileSync, existsSync } = await import('fs')
51
+ const { resolve } = await import('path')
52
+ const { homedir } = await import('os')
53
+ const yaml = await import('js-yaml')
54
+
55
+ const projectsFile = resolve(homedir(), '.acp', 'projects.yaml')
56
+ if (!existsSync(projectsFile)) return null
57
+
58
+ const raw = readFileSync(projectsFile, 'utf-8')
59
+ const doc = yaml.load(raw, { json: true }) as Record<string, unknown>
60
+ const projects = (doc?.projects || {}) as Record<string, Record<string, unknown>>
61
+ const project = projects[data.projectId]
62
+ if (!project) return null
63
+
64
+ const progressPath = resolve(String(project.path), 'agent', 'progress.yaml')
65
+ return existsSync(progressPath) ? progressPath : null
66
+ } catch {
67
+ return null
68
+ }
69
+ })
package/vite.config.ts CHANGED
@@ -3,9 +3,14 @@ import { tanstackStart } from '@tanstack/react-start/plugin/vite'
3
3
  import viteReact from '@vitejs/plugin-react'
4
4
  import viteTsConfigPaths from 'vite-tsconfig-paths'
5
5
  import tailwindcss from '@tailwindcss/vite'
6
+ import { cloudflare } from '@cloudflare/vite-plugin'
6
7
 
7
- export default defineConfig({
8
+ export default defineConfig(({ command }) => ({
8
9
  plugins: [
10
+ cloudflare({
11
+ viteEnvironment: { name: 'ssr' },
12
+ ...(command === 'serve' ? { config: { observability: { enabled: false } } } : {}),
13
+ }),
9
14
  viteTsConfigPaths({
10
15
  projects: ['./tsconfig.json'],
11
16
  }),
@@ -13,4 +18,4 @@ export default defineConfig({
13
18
  tanstackStart(),
14
19
  viteReact(),
15
20
  ],
16
- })
21
+ }))