create-einja-app 0.3.1 → 0.3.2

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/cli.js +32 -16
  3. package/dist/cli.js.map +1 -1
  4. package/package.json +1 -1
  5. package/templates/default/.claude/hooks/einja/plan-mode-skill-loader.sh +23 -0
  6. package/templates/default/.claude/settings.json +15 -1
  7. package/templates/default/.env.personal.example +6 -2
  8. package/templates/default/.envrc +5 -0
  9. package/templates/default/.github/workflows/deploy-pr-preview.yml +23 -24
  10. package/templates/default/.github/workflows/deploy-stable-branches.yml +55 -49
  11. package/templates/default/.mcp.json +2 -12
  12. package/templates/default/.serena/project.yml +7 -0
  13. package/templates/default/CLAUDE.md +28 -4
  14. package/templates/default/README.md +2 -2
  15. package/templates/default/apps/admin/package.json +1 -1
  16. package/templates/default/apps/admin/tsconfig.json +2 -1
  17. package/templates/default/apps/web/package.json +1 -1
  18. package/templates/default/apps/web/tsconfig.json +2 -1
  19. package/templates/default/docs/plans/.gitkeep +0 -0
  20. package/templates/default/docs/plans/ancient-greeting-flamingo-agent-a87e67c.md +221 -0
  21. package/templates/default/docs/plans/ancient-greeting-flamingo-agent-ab73a1c.md +107 -0
  22. package/templates/default/docs/plans/ancient-greeting-flamingo.md +120 -0
  23. package/templates/default/docs/plans/bright-stargazing-dawn.md +87 -0
  24. package/templates/default/docs/plans/calm-stirring-bonbon.md +196 -0
  25. package/templates/default/docs/plans/calm-watching-widget.md +111 -0
  26. package/templates/default/docs/plans/cheerful-wiggling-ullman.md +164 -0
  27. package/templates/default/docs/plans/compiled-humming-cherny.md +94 -0
  28. package/templates/default/docs/plans/dapper-launching-lynx.md +81 -0
  29. package/templates/default/docs/plans/effervescent-munching-kite-agent-ac08baf.md +672 -0
  30. package/templates/default/docs/plans/effervescent-munching-kite-agent-aecc373.md +442 -0
  31. package/templates/default/docs/plans/effervescent-munching-kite.md +263 -0
  32. package/templates/default/docs/plans/fix-orphan-cleaner-review.md +25 -0
  33. package/templates/default/docs/plans/fix-sync-template-variables.md +162 -0
  34. package/templates/default/docs/plans/glimmering-giggling-sedgewick.md +126 -0
  35. package/templates/default/docs/plans/glittery-swimming-bachman.md +78 -0
  36. package/templates/default/docs/plans/happy-watching-toast.md +56 -0
  37. package/templates/default/docs/plans/harmonic-strolling-nebula.md +210 -0
  38. package/templates/default/docs/plans/import-alias-refactor.md +75 -0
  39. package/templates/default/docs/plans/lazy-percolating-sloth-agent-abda679.md +346 -0
  40. package/templates/default/docs/plans/lazy-percolating-sloth.md +151 -0
  41. package/templates/default/docs/plans/linked-greeting-llama-agent-a7a6e5b.md +345 -0
  42. package/templates/default/docs/plans/linked-greeting-llama.md +467 -0
  43. package/templates/default/docs/plans/lovely-bubbling-rose.md +80 -0
  44. package/templates/default/docs/plans/optimized-watching-sprout.md +149 -0
  45. package/templates/default/docs/plans/peaceful-beaming-toast-agent-a292da6.md +288 -0
  46. package/templates/default/docs/plans/peaceful-beaming-toast-agent-a819699.md +366 -0
  47. package/templates/default/docs/plans/peaceful-beaming-toast-agent-ac11de2.md +474 -0
  48. package/templates/default/docs/plans/peaceful-beaming-toast.md +345 -0
  49. package/templates/default/docs/plans/purrfect-spinning-hickey-agent-ae6194c.md +300 -0
  50. package/templates/default/docs/plans/purrfect-spinning-hickey-agent-ae6900e.md +444 -0
  51. package/templates/default/docs/plans/purrfect-spinning-hickey.md +361 -0
  52. package/templates/default/docs/plans/recursive-kindling-lemon-agent-a42199e.md +186 -0
  53. package/templates/default/docs/plans/recursive-kindling-lemon.md +36 -0
  54. package/templates/default/docs/plans/seed-migration-tests.md +47 -0
  55. package/templates/default/docs/plans/sprightly-leaping-manatee.md +224 -0
  56. package/templates/default/docs/plans/stateful-wishing-lerdorf.md +161 -0
  57. package/templates/default/docs/plans/streamed-purring-wreath.md +40 -0
  58. package/templates/default/docs/plans/synthetic-percolating-pearl.md +101 -0
  59. package/templates/default/docs/plans/todo-fix-sync-template-variables.md +21 -0
  60. package/templates/default/docs/plans/todo-phase4-marker-update.md +39 -0
  61. package/templates/default/docs/plans/todo-skill-creator-sync.md +23 -0
  62. package/templates/default/docs/plans/typed-snuggling-parnas-agent-a6f6391.md +476 -0
  63. package/templates/default/docs/plans/typed-snuggling-parnas-agent-adb678b.md +144 -0
  64. package/templates/default/docs/plans/typed-snuggling-parnas.md +84 -0
  65. package/templates/default/docs/plans/warm-hopping-lighthouse-agent-a30aa4f.md +534 -0
  66. package/templates/default/docs/plans/warm-hopping-lighthouse-agent-a57a278.md +508 -0
  67. package/templates/default/docs/plans/warm-hopping-lighthouse-agent-a90b809.md +421 -0
  68. package/templates/default/docs/plans/warm-hopping-lighthouse.md +199 -0
  69. package/templates/default/docs/verification-test.md +2 -0
  70. package/templates/default/gitignore +4 -0
  71. package/templates/default/package.json +2 -2
  72. package/templates/default/packages/admin-ui/package.json +1 -1
  73. package/templates/default/packages/server-core/tsconfig.json +6 -1
  74. package/templates/default/pnpm-lock.yaml +276 -57
  75. package/templates/default/scripts/ensure-serena.sh +75 -0
  76. package/templates/default/scripts/lib/worktree-config.ts +64 -0
  77. package/templates/default/scripts/stop-serena.sh +25 -0
  78. package/templates/default/scripts/worktree/dev.ts +2 -2
  79. /package/templates/default/scripts/{cli-template-update.ts → _cli-template-update.ts} +0 -0
  80. /package/templates/default/scripts/{template-update.ts → _template-update.ts} +0 -0
@@ -0,0 +1,75 @@
1
+ #!/bin/bash
2
+ # Serena MCP サーバーの冪等起動
3
+ # .envrc から source して使用
4
+
5
+ # メインワークツリーをベースにする(worktree 間で共有)
6
+ _SERENA_BASE="${1:-$(pwd)}"
7
+ _SERENA_PORT_FILE="$_SERENA_BASE/.serena-port"
8
+ _SERENA_DEFAULT_PORT="${SERENA_PORT:-9850}"
9
+
10
+ # --- 既存インスタンスチェック(PIDベース) ---
11
+ if [ -f "$_SERENA_PORT_FILE" ]; then
12
+ read -r _saved_port _saved_pid < "$_SERENA_PORT_FILE"
13
+ if [ -n "$_saved_pid" ] && kill -0 "$_saved_pid" 2>/dev/null; then
14
+ # PIDが生存 → 自プロジェクトのSerena
15
+ export SERENA_PORT="$_saved_port"
16
+ return 0 2>/dev/null || true
17
+ fi
18
+ # PID死亡 → クリーンアップ
19
+ rm -f "$_SERENA_PORT_FILE"
20
+ fi
21
+
22
+ # --- uvx 確認 ---
23
+ if ! command -v uvx &> /dev/null; then
24
+ echo "[ensure-serena] Warning: uvx not found. Serena will not auto-start." >&2
25
+ echo "[ensure-serena] Install uv first: curl -LsSf https://astral.sh/uv/install.sh | sh" >&2
26
+ return 0 2>/dev/null || true
27
+ fi
28
+
29
+ # --- 空きポート検出 ---
30
+ _port="$_SERENA_DEFAULT_PORT"
31
+ _port_found=false
32
+ for _i in $(seq 1 10); do
33
+ if ! lsof -i ":$_port" -sTCP:LISTEN > /dev/null 2>&1; then
34
+ _port_found=true
35
+ break
36
+ fi
37
+ _port=$((_port + 1))
38
+ done
39
+
40
+ if [ "$_port_found" = false ]; then
41
+ echo "[ensure-serena] Error: No available port found (tried $_SERENA_DEFAULT_PORT-$_port)" >&2
42
+ return 0 2>/dev/null || true
43
+ fi
44
+
45
+ # --- バックグラウンド起動 ---
46
+ echo "[ensure-serena] Starting Serena on port $_port..."
47
+ uvx --from git+https://github.com/oraios/serena \
48
+ serena start-mcp-server \
49
+ --transport streamable-http \
50
+ --host 127.0.0.1 \
51
+ --port "$_port" \
52
+ --context claude-code \
53
+ --project "$_SERENA_BASE" \
54
+ > /dev/null 2>&1 &
55
+ _serena_pid=$!
56
+ disown
57
+
58
+ # --- 起動待機(PID生存 + ポートLISTEN、最大30秒) ---
59
+ for _i in $(seq 1 60); do
60
+ if ! kill -0 "$_serena_pid" 2>/dev/null; then
61
+ echo "[ensure-serena] Warning: Serena process exited unexpectedly" >&2
62
+ return 0 2>/dev/null || true
63
+ fi
64
+ if lsof -p "$_serena_pid" -i ":$_port" -sTCP:LISTEN > /dev/null 2>&1; then
65
+ echo "$_port $_serena_pid" > "$_SERENA_PORT_FILE"
66
+ export SERENA_PORT="$_port"
67
+ echo "[ensure-serena] Serena ready on port $_port (PID: $_serena_pid)"
68
+ return 0 2>/dev/null || true
69
+ fi
70
+ sleep 0.5
71
+ done
72
+
73
+ # タイムアウト(起動失敗してもdirenvはブロックしない)
74
+ echo "[ensure-serena] Warning: Serena failed to start within 30s" >&2
75
+ return 0 2>/dev/null || true
@@ -0,0 +1,64 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+
4
+ export interface AppConfig {
5
+ id: string;
6
+ portRangeStart: number;
7
+ rangeSize: number;
8
+ }
9
+
10
+ export interface PostgresConfig {
11
+ port: number;
12
+ containerName: string;
13
+ }
14
+
15
+ export interface WorktreeConfig {
16
+ schemaVersion: number;
17
+ postgres: PostgresConfig;
18
+ apps: AppConfig[];
19
+ }
20
+
21
+ const defaultWorktreeConfig: WorktreeConfig = {
22
+ schemaVersion: 1,
23
+ postgres: { port: 25432, containerName: "einja-management-postgres" },
24
+ apps: [{ id: "web", portRangeStart: 3000, rangeSize: 1000 }],
25
+ };
26
+
27
+ function findProjectRoot(startDir: string = process.cwd()): string | null {
28
+ let currentDir = startDir;
29
+ while (currentDir !== path.dirname(currentDir)) {
30
+ if (fs.existsSync(path.join(currentDir, "package.json"))) {
31
+ return currentDir;
32
+ }
33
+ currentDir = path.dirname(currentDir);
34
+ }
35
+ return null;
36
+ }
37
+
38
+ export function loadWorktreeConfig(projectRoot?: string): WorktreeConfig {
39
+ const root = projectRoot ?? findProjectRoot();
40
+ if (!root) return defaultWorktreeConfig;
41
+
42
+ const configPath = path.join(root, "worktree.config.json");
43
+ if (!fs.existsSync(configPath)) return defaultWorktreeConfig;
44
+
45
+ try {
46
+ const raw = JSON.parse(fs.readFileSync(configPath, "utf-8"));
47
+ return {
48
+ schemaVersion: raw.schemaVersion ?? 1,
49
+ postgres: {
50
+ port: typeof raw.postgres?.port === "number" ? raw.postgres.port : 25432,
51
+ containerName: typeof raw.postgres?.containerName === "string"
52
+ ? raw.postgres.containerName : "einja-management-postgres",
53
+ },
54
+ apps: Array.isArray(raw.apps)
55
+ ? raw.apps.filter((a: unknown) =>
56
+ typeof a === "object" && a !== null && "id" in a && "portRangeStart" in a
57
+ )
58
+ : defaultWorktreeConfig.apps,
59
+ };
60
+ } catch {
61
+ console.warn("worktree.config.json の読み込みに失敗。デフォルト設定を使用します。");
62
+ return defaultWorktreeConfig;
63
+ }
64
+ }
@@ -0,0 +1,25 @@
1
+ #!/bin/bash
2
+ PORT_FILE=".serena-port"
3
+ if [ -f "$PORT_FILE" ]; then
4
+ read -r PORT PID < "$PORT_FILE"
5
+ if [ -n "$PID" ] && kill -0 "$PID" 2>/dev/null; then
6
+ kill "$PID"
7
+ # SIGTERM後、最大5秒待機
8
+ for _i in $(seq 1 10); do
9
+ if ! kill -0 "$PID" 2>/dev/null; then
10
+ echo "Serena stopped (PID: $PID, port: $PORT)"
11
+ rm -f "$PORT_FILE"
12
+ exit 0
13
+ fi
14
+ sleep 0.5
15
+ done
16
+ # 応答なし → 強制終了
17
+ kill -9 "$PID" 2>/dev/null
18
+ echo "Serena force-killed (PID: $PID, port: $PORT)"
19
+ else
20
+ echo "Serena process not running (PID: $PID)"
21
+ fi
22
+ rm -f "$PORT_FILE"
23
+ else
24
+ echo "Serena not running (.serena-port not found)"
25
+ fi
@@ -11,8 +11,8 @@ import crypto from "node:crypto";
11
11
  import fs from "node:fs";
12
12
  import path from "node:path";
13
13
  import readline from "node:readline";
14
- import type { AppConfig, WorktreeConfig } from "../../packages/config/src/worktree-config.js";
15
- import { loadWorktreeConfig } from "../../packages/config/src/worktree-config-loader.js";
14
+ import type { AppConfig, WorktreeConfig } from "../lib/worktree-config.js";
15
+ import { loadWorktreeConfig } from "../lib/worktree-config.js";
16
16
 
17
17
  /** 設定を保持するグローバル変数 */
18
18
  let config: WorktreeConfig;