@simplysm/sd-claude 13.0.84 → 13.0.85

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.
@@ -9,6 +9,8 @@
9
9
  ## Playwright Rules
10
10
 
11
11
  - All Playwright output (screenshots, PDFs, downloads, etc.) must be saved to the `.tmp/playwright/` directory.
12
+ - When using Playwright MCP tools with a `filename` parameter, always prefix the filename with `.tmp/playwright/` (e.g., `filename: ".tmp/playwright/my-screenshot.png"`).
13
+ - Never pass a bare filename without the `.tmp/playwright/` path prefix.
12
14
 
13
15
  ## Documentation Rules for LLMs
14
16
 
@@ -0,0 +1,7 @@
1
+ # Simplysm Library Issue Reporting
2
+
3
+ Source code for `@simplysm/*` packages can be found in `node_modules/@simplysm/`. If debugging reveals the root cause is in the simplysm library itself, generate a GitHub issue-formatted text (title, reproduction steps, expected behavior, actual behavior) and display it to the user.
4
+
5
+ **Report facts only — do not suggest fixes or include code location hints. Do not auto-submit the issue — only display the text.**
6
+
7
+ The issue body must NEVER include internal analysis of library code (class names, variable names, style properties, inheritance chains, etc.). Only describe user-observable symptoms.
@@ -218,8 +218,11 @@ def main():
218
218
  model = format_model(model_id) if model_id else "?"
219
219
 
220
220
  # Extract context %
221
- ctx_pct = stdin_data.get("context_window", {}).get("used_percentage")
222
- ctx_str = f"{ctx_pct}%" if ctx_pct is not None else "?"
221
+ ctx_window = stdin_data.get("context_window")
222
+ if ctx_window is not None:
223
+ ctx_str = f"{ctx_window.get('used_percentage') or 0}%"
224
+ else:
225
+ ctx_str = "?"
223
226
 
224
227
  # Read cached usage data
225
228
  cache = read_cache()
@@ -83,7 +83,3 @@ Improvement:
83
83
  ## Step 5: Execute the Plan
84
84
 
85
85
  Once sd-plan is complete and a finalized plan is produced, modify the code according to that plan.
86
-
87
- ## Step 6: Recommend README Update
88
-
89
- If code modifications were made, recommend the user to run `/sd-readme`.
@@ -54,7 +54,11 @@ Invoke `sd-debug` via the Skill tool. Pass the following content as args:
54
54
 
55
55
  ```
56
56
  Analyze the code errors from the check results below.
57
- **Important: After completing Step 2 (in-depth codebase analysis), skip Steps 3-5 and immediately fix the code based on the analysis results. Do not output a diagnostic report, do not wait for user confirmation, and do not invoke sd-plan — apply fixes directly.**
57
+ **Important workflow instructions:**
58
+ 1. Perform Steps 1-2 thoroughly — gather problem information and conduct in-depth codebase analysis to identify the root cause. Do NOT skip or rush these steps.
59
+ 2. Output the diagnostic report from Step 3, but skip the user confirmation (do not call AskUserQuestion).
60
+ 3. Skip Steps 4-5 (do not invoke sd-plan).
61
+ 4. Based on the analysis results and diagnostic report, apply fixes directly.
58
62
 
59
63
  <Include the error content from the check result file here>
60
64
  ```
@@ -7,6 +7,33 @@ description: This skill is used when the user requests "make a plan", "create a
7
7
 
8
8
  Receives a task request from the user, generates an initial plan, then iteratively reviews and asks questions about unclear parts to produce a perfectly clear plan.
9
9
 
10
+ ## MANDATORY RULE — ONE QUESTION PER AskUserQuestion CALL
11
+
12
+ **Every AskUserQuestion call MUST have exactly 1 item in the `questions` array. NEVER bundle 2+ questions.**
13
+
14
+ WRONG — bundling multiple questions:
15
+ ```
16
+ questions: [
17
+ { question: "Which API style?" ... },
18
+ { question: "Which styling approach?" ... },
19
+ { question: "What default value?" ... }
20
+ ]
21
+ ```
22
+
23
+ RIGHT — one question per call, sequential:
24
+ ```
25
+ // Call 1
26
+ questions: [{ question: "Which API style?" ... }]
27
+ // Wait for answer → apply → re-extract unclear items
28
+ // Call 2
29
+ questions: [{ question: "Which styling approach?" ... }]
30
+ // Wait for answer → apply → re-extract unclear items
31
+ // Call 3
32
+ questions: [{ question: "What default value?" ... }]
33
+ ```
34
+
35
+ **Violating this rule makes the output unusable. There is NO exception.**
36
+
10
37
  ---
11
38
 
12
39
  ## Step 1: Input Verification
@@ -23,26 +50,47 @@ Receives a task request from the user, generates an initial plan, then iterative
23
50
 
24
51
  ### 2-1. Draft Creation
25
52
 
26
- Draft the plan. Always follow TDD principles:
27
- - For code tasks → Write test code first
28
- - For non-code tasks Define a self-verification checklist first
29
- - For code tasks where the project has no test environment set up → Propose verification methods such as CLI or dry-run
53
+ Draft the plan. **Every implementation item MUST be structured as 3 sub-steps: RED → Implement → GREEN.** NEVER skip or merge these sub-steps regardless of task simplicity.
54
+
55
+ Classify the task first, then apply the matching TDD approach:
56
+
57
+ **If code + test env exists:**
58
+ 1. **RED** — Write a failing test file, run it → confirm FAIL
59
+ 2. **Implement** — Write the minimum code to pass
60
+ 3. **GREEN** — Run the test → confirm PASS
61
+
62
+ **If code + no test env:**
63
+ 1. **RED** — Define a CLI/dry-run command, run it → confirm FAIL
64
+ 2. **Implement** — Write the minimum code to pass
65
+ 3. **GREEN** — Run the same command → confirm PASS
66
+
67
+ **If non-code (config, docs, prompts, SKILL.md, etc.):**
68
+ Prompt/config files cannot be unit-tested. Use **Agent behavioral simulation**: launch an Agent that reads the file and naturally follows its instructions with a sample task. **Do NOT tell the Agent what behavior you are testing** (this biases the result and invalidates the test).
69
+ 1. **RED** — `git stash` your changes → launch Agent with a sample task against the **original** file → confirm the Agent's output shows the **problematic** behavior (FAIL)
70
+ 2. **Implement** — `git stash pop` to restore changes, then apply your edits
71
+ 3. **GREEN** — launch same Agent with the same task against the **modified** file → confirm the Agent's output shows the **desired** behavior (PASS). If FAIL → fix implementation → re-run GREEN until PASS.
30
72
 
31
73
  ### 2-2. Clarification Cycle
32
74
 
33
- Repeat the following **until there are 0 unclear items**:
75
+ **This is a single-item loop. Each iteration handles exactly ONE unclear item, then restarts from scratch.**
34
76
 
35
- 1. **Extract**: Compare the plan against all 12 "Ambiguity Criteria" listed below and enumerate all unclear items.
36
- 2. **Dependency analysis**: Identify dependencies between items. ("A must be decided before B can be asked" → B depends on A)
37
- 3. **Ask**: For items with no dependencies, use AskUserQuestion with **exactly one question per tool call**. Provide 2-5 options for each question.
38
- - For each item, repeat "present one explanation -> AskUserQuestion"
39
- 4. **Apply**: Incorporate all answers to update the plan, then return to step 1.
77
+ 1. **Extract**: Compare the plan against all 12 "Ambiguity Criteria" below enumerate unclear items.
78
+ - 0 unclear items **STOP this loop. Go to Step 2.5.**
79
+ 2. **Dependency analysis**: Identify dependencies. ("A must be decided before B" B depends on A)
80
+ 3. **Ask exactly ONE question**: Pick the single most important item with no unresolved dependencies.
81
+ a. Present a brief explanation of why this item is unclear.
82
+ b. Call AskUserQuestion with `questions` array containing **exactly 1 item**. Include 2-5 options.
83
+ c. **STOP and WAIT** for the user's answer. Do NOT plan, prepare, or output anything about the next question.
84
+ 4. **Apply**: Incorporate the answer into the plan.
85
+ 5. **RESTART from step 1** — re-extract ALL unclear items from scratch. The previous answer may have resolved multiple items or created new ones. Never assume the remaining questions are still valid.
40
86
 
41
- 0 unclear items Move to **Step 2.5 Final Verification**.
87
+ **NEVER ask 2+ questions before restarting the loop. NEVER plan ahead for "the next question". Each loop iteration = 1 Extract + 1 Question + 1 Answer.**
42
88
 
43
89
  ### Ambiguity Criteria
44
90
 
45
91
  > **Core principle**: Anything not explicitly stated by the user and not confirmed in the codebase is **treated as speculation/assumption** and classified as an unclear item. Even if Claude wrote it confidently, it is unclear if the source is unverified.
92
+ >
93
+ > **Exception — implementation details are NOT unclear items**: Technical decisions about HOW to achieve the goal (code placement, internal structure, naming conventions, file organization, etc.) are Claude's engineering judgment. Only user-facing requirements (WHAT behavior the user wants) should be classified as unclear. If the user did not specify it and it is purely a technical approach decision, Claude decides — do NOT ask the user.
46
94
 
47
95
  Compare against all 12 items below **during every review**. To skip an item as "not applicable", there must be concrete evidence (user statement or codebase confirmation).
48
96
 
@@ -88,17 +136,30 @@ If the user approves, Write the plan to `.tmp/plans/${TS}_{topic}.md`.
88
136
 
89
137
  ## Step 4: Post-Implementation Guidance
90
138
 
91
- If the user approves implementation, implement according to the plan. Once implementation is complete, output the following guidance:
139
+ If the user approves implementation, implement according to the plan. Follow the TDD approach defined in Step 2-1 for the task type. **Do NOT proceed to the next item until the current item reaches GREEN.**
140
+
141
+ ### TDD Execution Rules
142
+
143
+ **RED and GREEN must be actually executed. NEVER skip or substitute them.**
144
+
145
+ - "User already confirmed the issue" is NOT a valid RED. Run the test yourself.
146
+ - "Needs a separate session to verify" is NOT a valid GREEN. Run the test yourself.
147
+ - If GREEN fails → fix the implementation → re-run GREEN. Repeat until it passes.
148
+
149
+ Once all items are complete, output the following guidance. Include only the items whose conditions are met, numbered sequentially:
92
150
 
93
- - **If code changes are included**:
94
- ```
95
- Implementation is complete. It is recommended to run the following steps in order:
96
- 1. /sd-checkType check + lint + test inspection and auto-fix
97
- 2. /sd-simplifySimplification review of changed code
98
- 3. /sd-commit — Commit changes
99
- ```
151
+ | Condition | Recommendation |
152
+ |-----------|----------------|
153
+ | Code changes exist | `/sd-check` Type check + lint + test inspection and auto-fix |
154
+ | Code changes exist | `/sd-simplify`Simplification review of changed code |
155
+ | Public API changed (exports, public methods/properties, component props, etc.) | `/sd-readme`Update README documentation |
156
+ | Always | `/sd-commit` — Commit changes |
100
157
 
101
- - **If no code changes are involved** (configuration, documentation, etc.):
102
- ```
103
- Implementation is complete. Run /sd-commit to commit the changes.
104
- ```
158
+ Example (all conditions met):
159
+ ```
160
+ Implementation is complete. It is recommended to run the following steps in order:
161
+ 1. /sd-check — Type check + lint + test inspection and auto-fix
162
+ 2. /sd-simplify — Simplification review of changed code
163
+ 3. /sd-readme — Update README documentation
164
+ 4. /sd-commit — Commit changes
165
+ ```
@@ -30,7 +30,12 @@ Do not modify the code under any circumstances. Only compile and output a list o
30
30
 
31
31
  Write each finding in the following format:
32
32
  ```
33
- - **filepath:line** — Problem description — Suggested fix
33
+ - **filepath:line**
34
+ - Current code: (excerpt of the relevant code)
35
+ - Problem description:
36
+ - Suggested fix:
37
+ - Reasons to fix: Rationale for applying the fix
38
+ - Reasons not to fix: Rationale for keeping the current code
34
39
  ```
35
40
 
36
41
  If no findings are discovered, display "No potential bugs were found." and stop.
@@ -52,9 +57,11 @@ When asking the user about uncertain fixes, **always present** the following inf
52
57
  ```
53
58
  Fix:
54
59
  - Filepath:line:
55
- - Problem description:
56
60
  - Current code: (excerpt of the relevant code)
61
+ - Problem description:
57
62
  - Suggested fix:
63
+ - Reasons to fix:
64
+ - Reasons not to fix:
58
65
  ```
59
66
 
60
67
  <Full list of findings from Step 2>
@@ -24,7 +24,12 @@ Invoke `simplify` using the Skill tool. Pass the following instructions as args:
24
24
  Review the current codebase at the <target path> path. (Not recently changed code)
25
25
  Do NOT modify any code. Only compile and output a list of items to fix.
26
26
  Write each item in the following format:
27
- - **file-path:line** — Problem description — Suggested improvement
27
+ - **file-path:line**
28
+ - Current code: (excerpt of the relevant code)
29
+ - Problem description:
30
+ - Suggested improvement:
31
+ - Reasons to change: Rationale for applying the improvement
32
+ - Reasons not to change: Rationale for keeping the current code
28
33
  ```
29
34
 
30
35
  Replace the `<target path>` placeholder with the actual path extracted in Step 1.
@@ -46,9 +51,11 @@ When asking the user about unclear suggestions, **always present** the following
46
51
  ```
47
52
  Suggestion:
48
53
  - File path:line:
49
- - Problem description:
50
54
  - Current code: (excerpt of the relevant code)
55
+ - Problem description:
51
56
  - Suggested improvement:
57
+ - Reasons to change:
58
+ - Reasons not to change:
52
59
  ```
53
60
 
54
61
  <Full list of items to fix from Step 2>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@simplysm/sd-claude",
3
- "version": "13.0.84",
3
+ "version": "13.0.85",
4
4
  "description": "Simplysm Claude Code asset installer",
5
5
  "author": "simplysm",
6
6
  "license": "Apache-2.0",
@@ -10,6 +10,9 @@
10
10
  "directory": "packages/sd-claude"
11
11
  },
12
12
  "type": "module",
13
+ "bin": {
14
+ "sd-claude": "scripts/cli.mjs"
15
+ },
13
16
  "files": [
14
17
  "scripts",
15
18
  "claude"
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+
3
+ const command = process.argv[2];
4
+
5
+ if (command === "postinstall") {
6
+ await import("./postinstall.mjs");
7
+ } else {
8
+ console.log("Usage: sd-claude <command>");
9
+ console.log("Commands:");
10
+ console.log(" postinstall Install Claude Code assets to .claude/");
11
+ process.exit(1);
12
+ }
@@ -46,7 +46,7 @@ try {
46
46
  console.warn("[@simplysm/sd-claude] postinstall warning:", err.message);
47
47
  }
48
48
 
49
- /** Finds the project root from INIT_CWD or node_modules path. */
49
+ /** Finds the project root from INIT_CWD, node_modules path, or cwd. */
50
50
  function findProjectRoot(dirname) {
51
51
  if (process.env["INIT_CWD"] != null) {
52
52
  return process.env["INIT_CWD"];
@@ -55,7 +55,12 @@ function findProjectRoot(dirname) {
55
55
  const sep = path.sep;
56
56
  const marker = sep + "node_modules" + sep;
57
57
  const idx = dirname.indexOf(marker);
58
- return idx !== -1 ? dirname.substring(0, idx) : undefined;
58
+ if (idx !== -1) {
59
+ return dirname.substring(0, idx);
60
+ }
61
+
62
+ // Fallback to cwd for manual CLI invocation (e.g., npx sd-claude postinstall)
63
+ return process.cwd();
59
64
  }
60
65
 
61
66
  /** Checks if this is the simplysm monorepo with the same major version. */
@@ -107,16 +112,27 @@ function setupSettings(targetDir) {
107
112
  // statusLine: always overwrite
108
113
  settings["statusLine"] = { type: "command", command: "python .claude/sd-statusline.py" };
109
114
 
115
+ // Migrate: move root-level SessionStart to hooks.SessionStart
116
+ if (settings["SessionStart"] != null) {
117
+ settings["hooks"] = settings["hooks"] ?? {};
118
+ settings["hooks"]["SessionStart"] = [
119
+ ...(settings["hooks"]["SessionStart"] ?? []),
120
+ ...settings["SessionStart"],
121
+ ];
122
+ delete settings["SessionStart"];
123
+ }
124
+
110
125
  // SessionStart: ensure sd-session-start hook exists with correct config
126
+ settings["hooks"] = settings["hooks"] ?? {};
111
127
  const sdSessionEntry = {
112
128
  matcher: "startup|resume|clear|compact",
113
129
  hooks: [{ type: "command", command: "bash .claude/sd-session-start.sh" }],
114
130
  };
115
131
 
116
- const sessionStart = settings["SessionStart"];
132
+ const sessionStart = settings["hooks"]["SessionStart"];
117
133
 
118
134
  if (sessionStart == null) {
119
- settings["SessionStart"] = [sdSessionEntry];
135
+ settings["hooks"]["SessionStart"] = [sdSessionEntry];
120
136
  } else {
121
137
  const idx = sessionStart.findIndex((entry) =>
122
138
  entry.hooks?.some((hook) => hook.command.includes("sd-session-start")),