@donotdev/cli 0.3.6 → 0.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@donotdev/cli",
3
- "version": "0.3.6",
3
+ "version": "0.3.8",
4
4
  "description": "Command-line interface for DoNotDev Framework",
5
5
  "type": "module",
6
6
  "private": false,
@@ -120,18 +120,6 @@ export default function HomePage() {
120
120
  ]}
121
121
  />
122
122
 
123
- <Card
124
- title="Staging Environment"
125
- subtitle="Separate Firebase project for testing"
126
- content={[
127
- 'Create a second Firebase project (e.g. my-app-staging)',
128
- 'Add to .firebaserc: { "projects": { "staging": "my-app-staging" } }',
129
- 'Create .env.staging with staging Firebase config',
130
- 'Create service-account-key.staging.json',
131
- 'Deploy with: dndev staging',
132
- ]}
133
- />
134
-
135
123
  <Card
136
124
  title="Secrets (Stripe, OAuth, etc.)"
137
125
  subtitle="Server-side API keys for Cloud Functions"
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Senior Developer — Execute coding tasks following framework patterns
3
- model: claude-sonnet-4.5
3
+ model: sonnet
4
4
  ---
5
5
 
6
6
  Persona and instructions are loaded by `start_phase()` for the current phase. Call it before starting work.
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  description: Product Owner + Architect — Prepare perfect coding prompts with all constraints
3
- model: claude-sonnet-4.5
3
+ model: sonnet
4
4
  ---
5
5
 
6
6
  Persona and instructions are loaded by `start_phase()` for the current phase. Call it before starting work.
@@ -2,7 +2,7 @@
2
2
  # .claude/hooks/guard-bash.sh
3
3
  # PreToolUse hook for Bash commands.
4
4
  # Blocks dangerous/wrong commands. Exit 2 = block, exit 0 = allow.
5
- # tsc / install checks look at command words only (not heredocs, quotes, comments).
5
+ # tsc / install / test-runner checks look at command words only (not heredocs, quotes, comments).
6
6
  # Uses bun -e for JSON parsing (bun-first project).
7
7
 
8
8
  set -euo pipefail
@@ -16,7 +16,7 @@ COMMAND=$(echo "$INPUT" | bun -e "process.stdout.write(JSON.parse(await Bun.stdi
16
16
  # Command-word analysis (tsc / package-manager install).
17
17
  # Splits the command into simple commands (on ; & | ( ) and newlines), ignoring quoted strings,
18
18
  # comments and heredoc bodies, then looks only at each command's leading words.
19
- # Prints "tsc" or "install" for the first offending simple command, nothing otherwise.
19
+ # Prints "tsc", "test" or "install" for the first offending simple command, nothing otherwise.
20
20
  ANALYZER=$(cat <<'JS'
21
21
  const src = await Bun.stdin.text();
22
22
  const cmds = [];
@@ -86,6 +86,7 @@ endCmd();
86
86
 
87
87
  const base = (w) => w.slice(w.lastIndexOf('/') + 1);
88
88
  const PM = ['bun', 'npm', 'yarn', 'pnpm'];
89
+ const TEST_RUNNERS = ['vitest', 'jest', 'playwright'];
89
90
  let verdict = '';
90
91
  for (const w0 of cmds) {
91
92
  let w = w0;
@@ -100,6 +101,8 @@ for (const w0 of cmds) {
100
101
  }
101
102
  if (head === 'tsc') { verdict = 'tsc'; break; }
102
103
  if (runner && rest.find((a) => !a.startsWith('-')) === 'tsc') { verdict = 'tsc'; break; }
104
+ if (PM.includes(head) && (rest[0] === 'test' || (rest[0] === 'run' && /^test(:|$)/.test(rest[1] ?? '')))) { verdict = 'test'; break; }
105
+ if (TEST_RUNNERS.includes(head) || (runner && TEST_RUNNERS.includes(rest.find((a) => !a.startsWith('-')) ?? ''))) { verdict = 'test'; break; }
103
106
  if (PM.includes(head) && (rest[0] === 'install' || rest[0] === 'i') && !verdict) verdict = 'install';
104
107
  }
105
108
  process.stdout.write(verdict);
@@ -113,6 +116,12 @@ if [ "$VERDICT" = "tsc" ]; then
113
116
  exit 2
114
117
  fi
115
118
 
119
+ # Block raw test runners (must use dn test: raw runners pick up the Playwright e2e specs)
120
+ if [ "$VERDICT" = "test" ]; then
121
+ echo "BLOCKED: Run tests with 'dn test --app <app>' (UAT: 'dn test:uat'), never raw bun test / vitest / playwright: they pick up the e2e specs and report false failures." >&2
122
+ exit 2
123
+ fi
124
+
116
125
  # Block reinstall once dependencies are installed (the first install of a fresh scaffold is allowed)
117
126
  # bun add IS allowed — consumer projects may need additional packages
118
127
  if [ "$VERDICT" = "install" ] && [ -d "${CLAUDE_PROJECT_DIR:-.}/node_modules" ]; then
@@ -1,50 +1,41 @@
1
1
  #!/bin/bash
2
- # .claude/hooks/session-start.sh
3
- # Injects context at session start so the agent doesn't fly blind.
4
- # Cross-platform: bun-first, no grep -P.
2
+ # .claude/hooks/session-start.sh [subagent]
3
+ # SessionStart (startup, /clear, compaction): active phase + project lessons, plain text.
4
+ # SubagentStart (arg "subagent"): project lessons as additionalContext JSON, so every
5
+ # subagent gets them without a brief carrying them. Explore gets nothing (read-only search);
6
+ # Plan starts without CLAUDE.md, so it is told to read AGENTS.md and the rules.
7
+ # Lessons: .dndev/LESSONS.md bullets, deprecated and anti-pattern ones left out, score suffix stripped.
5
8
 
6
9
  set -euo pipefail
7
10
 
8
- echo "=== SESSION CONTEXT ==="
11
+ cd "$CLAUDE_PROJECT_DIR"
9
12
 
10
- # Git branch
11
- BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
12
- echo "Branch: $BRANCH"
13
+ bun -e '
14
+ const mode = process.argv[1] ?? "session";
15
+ const read = async (p) => ((await Bun.file(p).exists()) ? Bun.file(p).text() : "");
13
16
 
14
- # Dirty files count
15
- DIRTY=$(git status --porcelain 2>/dev/null | wc -l | tr -d ' ')
16
- if [ "$DIRTY" -gt 0 ]; then
17
- echo "Dirty files: $DIRTY"
18
- git status --porcelain 2>/dev/null | head -10
19
- [ "$DIRTY" -gt 10 ] && echo " ... and $((DIRTY - 10)) more"
20
- fi
17
+ const lessons = (await read(".dndev/LESSONS.md"))
18
+ .split("\n")
19
+ .filter((l) => l.startsWith("- [") && !/status:(deprecated|anti-pattern)/.test(l))
20
+ .map((l) => l.replace(/\s*\{helpful:\d+,harmful:\d+,lastSeen:[^}]+\}$/, ""));
21
+ const lessonsBlock = lessons.length
22
+ ? "Project lessons (owner rules learned the hard way; they override your defaults):\n" + lessons.join("\n")
23
+ : "";
21
24
 
22
- # WAI-WAY phase status (if dndev is available)
23
- if command -v dndev &>/dev/null; then
24
- PHASE_FILE=".dndev/implementation.md"
25
- if [ -f "$PHASE_FILE" ]; then
26
- CURRENT=$(bun -e "
27
- const text = await Bun.file('$PHASE_FILE').text();
28
- const m = text.match(/Current Phase:\\s*(.+)/);
29
- process.stdout.write(m ? m[1].trim() : 'none');
30
- " 2>/dev/null || echo "none")
31
- echo "WAI-WAY Phase: $CURRENT"
32
- else
33
- echo "WAI-WAY Phase: not started - call start_phase(0)"
34
- fi
35
- fi
25
+ if (mode === "subagent") {
26
+ const { agent_type } = JSON.parse(await Bun.stdin.text());
27
+ if (agent_type === "Explore") process.exit(0);
28
+ const parts = [lessonsBlock];
29
+ if (agent_type === "Plan") parts.unshift("Read AGENTS.md and every .claude/rules/*.md file before you plan: they are the project rules.");
30
+ const context = parts.filter(Boolean).join("\n\n");
31
+ if (context) process.stdout.write(JSON.stringify({ hookSpecificOutput: { hookEventName: "SubagentStart", additionalContext: context } }));
32
+ process.exit(0);
33
+ }
36
34
 
37
- # Recent lessons (last 3)
38
- LESSONS_FILE=".dndev/LESSONS.md"
39
- if [ -f "$LESSONS_FILE" ]; then
40
- LESSON_COUNT=$(grep -c '^## ' "$LESSONS_FILE" 2>/dev/null || echo "0")
41
- if [ "$LESSON_COUNT" -gt 0 ]; then
42
- echo ""
43
- echo "Recent lessons ($LESSON_COUNT total):"
44
- grep '^## ' "$LESSONS_FILE" | tail -3 | sed 's/^/ /'
45
- fi
46
- fi
47
-
48
- echo ""
49
- echo "REMINDER: Root instructions are in AGENTS.md. Use lookup_symbol before @donotdev imports."
50
- echo "=== END CONTEXT ==="
35
+ const protocolText = await read(".dndev/protocol.json");
36
+ const protocol = protocolText ? JSON.parse(protocolText) : {};
37
+ const phaseLine = Number.isInteger(protocol.currentPhase)
38
+ ? `DoNotDev phase: ${protocol.currentPhase} ${protocol.phaseName}. Call start_phase(${protocol.currentPhase}) before any work; if it fails, stop and report the exact error.`
39
+ : "DoNotDev phase: none started. Call start_phase(0) before any work; if it fails, stop and report the exact error.";
40
+ process.stdout.write([phaseLine, lessonsBlock].filter(Boolean).join("\n\n") + "\n");
41
+ ' "${1:-session}"
@@ -11,6 +11,17 @@
11
11
  ]
12
12
  }
13
13
  ],
14
+ "SubagentStart": [
15
+ {
16
+ "matcher": "",
17
+ "hooks": [
18
+ {
19
+ "type": "command",
20
+ "command": "bash \"$CLAUDE_PROJECT_DIR/.claude/hooks/session-start.sh\" subagent"
21
+ }
22
+ ]
23
+ }
24
+ ],
14
25
  "PreToolUse": [
15
26
  {
16
27
  "matcher": "Bash",
@@ -24,8 +24,7 @@ Open the app and follow the setup steps on the homepage (Git, Firebase, Stripe,
24
24
  │ └── my-app/
25
25
  │ ├── .env ← Vite reads THIS one
26
26
  │ ├── .env.local ← Overrides .env (gitignored)
27
- │ ├── .env.production ← Production overrides
28
- │ └── .env.staging ← Staging overrides (used by dndev staging)
27
+ │ └── .env.production ← Production overrides
29
28
  └── functions/
30
29
  └── .env ← Server-side secrets (Stripe, OAuth, etc.)
31
30
  ```
@@ -45,7 +44,6 @@ dndev emu start # Start Firebase emulators (Auth, Firestore, Functi
45
44
 
46
45
  # Deployment
47
46
  dndev deploy # Deploy to Firebase (hosting + functions + rules)
48
- dndev staging # Deploy to staging environment
49
47
  dndev sync-secrets # Push .dndev.secrets values to Firebase Secret Manager
50
48
 
51
49
  # Quality