its-magic 0.1.2-11 → 0.1.2-13

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.
@@ -10,18 +10,25 @@ description: "its-magic auto: run phases sequentially until decision gate."
10
10
 
11
11
  ## Inputs
12
12
  - `AUTO_FLOW_MODE` and `PHASE_MODE` from `.cursor/scratchpad.md`
13
+ - `AUTO_IMPLEMENTATION_LOOP`, `AUTO_LOOP_MAX_CYCLES` from `.cursor/scratchpad.md`
14
+ - `AUTO_PAUSE_REQUEST`, `AUTO_PAUSE_POLICY` from `.cursor/scratchpad.md`
13
15
  - Current product and engineering docs
14
16
 
15
17
  ## Outputs (artifacts)
16
18
  - Updated phase artifacts for each step
17
19
  - `docs/engineering/state.md`
18
20
  - `handoffs/resume_brief.md` if stopped
21
+ - `sprints/S0001/qa-findings.md` and `handoffs/qa_to_dev.md` when loop finds issues
19
22
 
20
23
  ## Stop conditions
21
24
  - Decision gate triggered
22
25
  - Missing critical input
26
+ - `AUTO_PAUSE_REQUEST=1` reached at a safe boundary
27
+ - `AUTO_LOOP_MAX_CYCLES` reached with unresolved defects
23
28
 
24
29
  ## Steps
25
30
  1. Read automation flags from scratchpad.
26
31
  2. Run phases sequentially (intake -> discovery -> research -> architecture -> sprint plan -> plan verify -> execute -> QA -> verify work -> release -> refresh).
27
- 3. Stop at decision gate or missing info and write resume brief.
32
+ 3. If `AUTO_IMPLEMENTATION_LOOP=1`, loop between `execute` and `QA` until QA has no blocking findings, then continue to `verify work` and `release`.
33
+ 4. If `AUTO_PAUSE_REQUEST=1`, complete the current safe boundary (`AUTO_PAUSE_POLICY`) and run `/pause` to persist checkpoint artifacts.
34
+ 5. Stop at decision gate or missing info and write resume brief.
@@ -10,6 +10,7 @@ description: "its-magic execute: implement tasks with artifacts and state update
10
10
  ## Inputs
11
11
  - `sprints/S0001/tasks.md`
12
12
  - `handoffs/tl_to_dev.md`
13
+ - Optional: `handoffs/qa_to_dev.md` when fixing QA findings
13
14
 
14
15
  ## Outputs (artifacts)
15
16
  - Code changes
@@ -29,4 +30,8 @@ description: "its-magic execute: implement tasks with artifacts and state update
29
30
  via the appropriate package manager without prompting.
30
31
  5. If `REMOTE_EXECUTION=1` and `.cursor/remote.json` is configured, use
31
32
  remote/docker servers for heavy builds or tests when needed.
33
+ 6. If `RUN_TESTS_ON_EDIT=1`, run configured tests after meaningful edits.
34
+ 7. If `LOOP_UNTIL_GREEN=1`, fix failing tests in small iterations until green,
35
+ or stop and document blockers in `docs/engineering/state.md`.
36
+ 8. If `AUTO_PAUSE_REQUEST=1` and boundary rules permit, checkpoint via `/pause`.
32
37
 
@@ -9,6 +9,7 @@ description: "its-magic pause: write checkpoint and resume brief."
9
9
 
10
10
  ## Inputs
11
11
  - Current sprint progress and state
12
+ - Optional intent: immediate pause or graceful pause after current boundary
12
13
 
13
14
  ## Outputs (artifacts)
14
15
  - `docs/engineering/state.md`
@@ -22,4 +23,8 @@ description: "its-magic pause: write checkpoint and resume brief."
22
23
  1. Write a short checkpoint of current work.
23
24
  2. Update sprint progress and state.
24
25
  3. Write a resume brief with next actions.
26
+ 4. Record the intended resume phase in `handoffs/resume_brief.md` (for example:
27
+ execute, qa, verify-work, release).
28
+ 5. If this pause was requested via `AUTO_PAUSE_REQUEST=1`, reset the flag to `0`
29
+ after checkpoint is complete.
25
30
 
@@ -24,5 +24,8 @@ description: "its-magic QA: test plan, findings, verify fixes."
24
24
  1. Define a test plan and run verification.
25
25
  2. Record findings and severity.
26
26
  3. Update state and handoff to dev if needed.
27
- 4. Follow with `/verify-work` for user acceptance.
27
+ 4. If `AUTO_IMPLEMENTATION_LOOP=1` and blocking issues exist, handoff to dev and
28
+ return to `/execute` automatically (bounded by `AUTO_LOOP_MAX_CYCLES`).
29
+ 5. Follow with `/verify-work` for user acceptance when blocking issues are closed.
30
+ 6. If `AUTO_PAUSE_REQUEST=1` at safe boundary, run `/pause` before next phase.
28
31
 
@@ -12,6 +12,7 @@ description: "its-magic resume: load context pack and continue work."
12
12
  - `docs/engineering/decisions.md`
13
13
  - `sprints/S0001/summary.md`
14
14
  - `handoffs/resume_brief.md`
15
+ - Optional automation flags from `.cursor/scratchpad.md`
15
16
 
16
17
  ## Outputs (artifacts)
17
18
  - Updated `docs/engineering/state.md` (if needed)
@@ -22,5 +23,7 @@ description: "its-magic resume: load context pack and continue work."
22
23
  ## Steps
23
24
  1. Load the context pack and open decisions.
24
25
  2. Summarize current status and next steps.
25
- 3. Hand off to the appropriate phase.
26
+ 3. Continue from the resume phase noted in `handoffs/resume_brief.md`.
27
+ 4. If `AUTO_FLOW_MODE=auto_until_decision`, continue automation until the next
28
+ decision gate, pause request, or blocker.
26
29
 
@@ -23,3 +23,5 @@ description: "its-magic verify work: guided user acceptance testing."
23
23
  1. Convert acceptance criteria into testable UAT steps.
24
24
  2. Record results and failures.
25
25
  3. Update state with pass/fail summary.
26
+ 4. If `AUTO_IMPLEMENTATION_LOOP=1` and UAT fails, write a handoff to dev/QA and
27
+ continue the fix loop within `AUTO_LOOP_MAX_CYCLES`.
@@ -9,5 +9,6 @@ Events handled:
9
9
  - afterFileEdit: tracks code edits vs context refresh
10
10
  - stop: optional reminder to refresh context
11
11
 
12
- Behavior is controlled via `.cursor/scratchpad.md`.
12
+ Behavior is controlled via `.cursor/scratchpad.md` with optional local overrides
13
+ from `.cursor/scratchpad.local.md`.
13
14
 
@@ -6,14 +6,15 @@ from datetime import datetime
6
6
 
7
7
  ROOT = os.path.abspath(os.path.join(os.path.dirname(__file__), "..", ".."))
8
8
  SCRATCHPAD = os.path.join(ROOT, ".cursor", "scratchpad.md")
9
+ SCRATCHPAD_LOCAL = os.path.join(ROOT, ".cursor", "scratchpad.local.md")
9
10
  STATE_FILE = os.path.join(ROOT, ".cursor", "hooks", "hook-state.json")
10
11
  BENCH_LOG = os.path.join(ROOT, ".cursor", "hooks", "bench-log.jsonl")
11
12
 
12
13
 
13
- def read_scratchpad():
14
+ def read_kv_file(path):
14
15
  flags = {}
15
16
  try:
16
- with open(SCRATCHPAD, "r", encoding="utf-8") as f:
17
+ with open(path, "r", encoding="utf-8") as f:
17
18
  for line in f:
18
19
  line = line.strip()
19
20
  if not line or line.startswith("#"):
@@ -26,6 +27,14 @@ def read_scratchpad():
26
27
  return flags
27
28
 
28
29
 
30
+ def read_scratchpad():
31
+ flags = read_kv_file(SCRATCHPAD)
32
+ # Local overrides are optional and intentionally gitignored.
33
+ local = read_kv_file(SCRATCHPAD_LOCAL)
34
+ flags.update(local)
35
+ return flags
36
+
37
+
29
38
  def load_state():
30
39
  try:
31
40
  with open(STATE_FILE, "r", encoding="utf-8") as f:
@@ -0,0 +1,29 @@
1
+ ---
2
+ description: "Strict coding standards and language best practices"
3
+ globs: ["**/*"]
4
+ ---
5
+
6
+ - Follow the official best practices of each language/framework used in the
7
+ changed files. Do not use deprecated APIs unless explicitly required.
8
+ - Keep behavior deterministic and explicit: avoid hidden side effects and
9
+ implicit global state.
10
+ - Prefer readability over cleverness. Use clear naming and small functions.
11
+ - Match existing project conventions for formatting, structure, and patterns.
12
+ - Keep interfaces stable and backward compatible unless the task requires a
13
+ breaking change (then document the break and migration steps).
14
+ - Validate input boundaries and handle errors intentionally (no silent catches).
15
+ - Never swallow exceptions without logging/context and a clear recovery path.
16
+ - Avoid duplicated logic; extract shared behavior when repetition appears.
17
+ - Minimize complexity: avoid unnecessary abstraction, deep nesting, and large
18
+ functions/classes.
19
+ - Use strict typing and contracts where available (TypeScript/Python typing/etc).
20
+ - No dead code, commented-out code blocks, or unused variables/imports.
21
+ - Add or update tests for behavior changes. Tests must verify outcomes, not only
22
+ implementation details.
23
+ - If tests/lint/typecheck fail for changed areas, fix before marking work done.
24
+ - Security by default: validate untrusted input, avoid injection-prone patterns,
25
+ and do not introduce secrets into code or artifacts.
26
+ - Performance by default: avoid obvious N+1 loops, repeated expensive work, and
27
+ unnecessary I/O in hot paths.
28
+ - Documentation by default: update relevant docs when behavior, setup, or usage
29
+ changes.
@@ -10,6 +10,11 @@ globs: ["**/*"]
10
10
  decision gates (`auto_until_decision` recommended).
11
11
  - `PHASE_MODE=interactive` means ask questions; `PHASE_MODE=auto` minimizes
12
12
  prompts unless decisions are required.
13
+ - `AUTO_IMPLEMENTATION_LOOP=1` enables an automatic fix loop:
14
+ execute -> QA -> execute (and verify-work) until quality gates are green or
15
+ `AUTO_LOOP_MAX_CYCLES` is reached.
16
+ - `AUTO_PAUSE_REQUEST=1` requests a graceful stop at the next safe boundary
17
+ defined by `AUTO_PAUSE_POLICY` (`after_task` or `after_phase`).
13
18
  - Persist decisions and state in files; do not keep critical info only in chat.
14
19
  - Pause/resume is first-class. Update `handoffs/resume_brief.md` on pause.
15
20
  - Context pack must stay compact: summarize, do not dump raw logs.
@@ -10,6 +10,9 @@ globs: ["**/*"]
10
10
  - If `AUTO_RELEASE_NOTES=1` in `.cursor/scratchpad.md`, generate release notes
11
11
  automatically (scripted).
12
12
  - If `PERMISSION_MODE=auto`, do not ask for routine permission prompts.
13
+ - If `RUN_TESTS_ON_EDIT=1`, run configured tests after meaningful edits.
14
+ - If `LOOP_UNTIL_GREEN=1`, iterate fix/test until green, bounded by
15
+ `AUTO_LOOP_MAX_CYCLES` when set.
13
16
  - Update `docs/engineering/state.md` after meaningful changes.
14
17
  - If tests fail and commands are set, fix or document before proceeding.
15
18
 
@@ -0,0 +1,36 @@
1
+ # its-magic scratchpad (local overrides example)
2
+ #
3
+ # Copy this file to `.cursor/scratchpad.local.md` and set your personal values.
4
+ # This file is intended to stay local and is gitignored.
5
+ #
6
+ # Team identity / ownership
7
+ # - TEAM_MODE: 0|1
8
+ # - TEAM_MEMBER: short id for current developer
9
+ # - ACTIVE_TASK_IDS: comma-separated task ids (for example T-12,T-13)
10
+ TEAM_MODE=0
11
+ TEAM_MEMBER=
12
+ ACTIVE_TASK_IDS=
13
+ #
14
+ # Personal automation style
15
+ # - PHASE_MODE: interactive|auto
16
+ # - PERMISSION_MODE: interactive|auto
17
+ # - RUN_TESTS_ON_EDIT: 0|1
18
+ # - LOOP_UNTIL_GREEN: 0|1
19
+ # - AUTO_IMPLEMENTATION_LOOP: 0|1
20
+ # - AUTO_LOOP_MAX_CYCLES: integer >= 1
21
+ # - AUTO_PAUSE_POLICY: after_task|after_phase
22
+ PHASE_MODE=interactive
23
+ PERMISSION_MODE=interactive
24
+ RUN_TESTS_ON_EDIT=0
25
+ LOOP_UNTIL_GREEN=0
26
+ AUTO_IMPLEMENTATION_LOOP=0
27
+ AUTO_LOOP_MAX_CYCLES=5
28
+ AUTO_PAUSE_POLICY=after_phase
29
+ #
30
+ # Personal environment preferences
31
+ # - AUTO_INSTALL_DEPS: 0|1
32
+ # - REMOTE_EXECUTION: 0|1
33
+ # - REMOTE_CONFIG: path to your local remote config
34
+ AUTO_INSTALL_DEPS=0
35
+ REMOTE_EXECUTION=0
36
+ REMOTE_CONFIG=.cursor/remote.json
@@ -1,13 +1,25 @@
1
1
  # its-magic scratchpad
2
2
  #
3
+ # Shared team defaults live here.
4
+ # Personal developer overrides belong in `.cursor/scratchpad.local.md`
5
+ # (copy from `.cursor/scratchpad.local.example.md`).
6
+ #
3
7
  # Core behavior
4
8
  # - MAGIC_CONTEXT_STRICT: 0|1 (require context refresh after code changes)
5
9
  # - LOOP_UNTIL_GREEN: 0|1 (optional test loop)
6
10
  # - RUN_TESTS_ON_EDIT: 0|1 (run tests after edits)
11
+ # - AUTO_IMPLEMENTATION_LOOP: 0|1 (auto cycle execute->qa->execute)
12
+ # - AUTO_LOOP_MAX_CYCLES: integer >= 1 (safety guard)
13
+ # - AUTO_PAUSE_REQUEST: 0|1 (request graceful stop at next safe boundary)
14
+ # - AUTO_PAUSE_POLICY: after_task|after_phase (safe stop boundary)
7
15
  # - DONE: 0|1 (stop hook loops)
8
16
  MAGIC_CONTEXT_STRICT=1
9
17
  LOOP_UNTIL_GREEN=0
10
18
  RUN_TESTS_ON_EDIT=0
19
+ AUTO_IMPLEMENTATION_LOOP=0
20
+ AUTO_LOOP_MAX_CYCLES=5
21
+ AUTO_PAUSE_REQUEST=0
22
+ AUTO_PAUSE_POLICY=after_phase
11
23
  DONE=0
12
24
  #
13
25
  # Benchmarking
@@ -6,6 +6,7 @@ on:
6
6
  pull_request:
7
7
 
8
8
  jobs:
9
+ # ── Unit / structure tests (from runbook) ──────────────────────────
9
10
  checks:
10
11
  runs-on: ubuntu-latest
11
12
  steps:
@@ -47,3 +48,116 @@ jobs:
47
48
  if: ${{ steps.runbook.outputs.TEST_COMMAND == '' && steps.runbook.outputs.LINT_COMMAND == '' && steps.runbook.outputs.TYPECHECK_COMMAND == '' }}
48
49
  run: echo "No runbook commands set."
49
50
 
51
+ # ── npm package test (Ubuntu) ──────────────────────────────────────
52
+ npm-test:
53
+ runs-on: ubuntu-latest
54
+ steps:
55
+ - uses: actions/checkout@v4
56
+ - uses: actions/setup-node@v4
57
+ with:
58
+ node-version: "20"
59
+ - name: npm pack
60
+ run: |
61
+ npm pack
62
+ TGZ=$(ls -t its-magic-*.tgz 2>/dev/null | head -1)
63
+ echo "TGZ=$TGZ" >> "$GITHUB_ENV"
64
+ echo "Package created: $TGZ"
65
+ - name: Install globally from tarball
66
+ run: npm install -g "$TGZ"
67
+ - name: Smoke test - help
68
+ run: its-magic --help
69
+ - name: Smoke test - install into temp dir
70
+ run: |
71
+ TEST_DIR=$(mktemp -d)
72
+ its-magic --target "$TEST_DIR" --mode missing --create
73
+ FAIL=0
74
+ for f in \
75
+ ".cursor/commands/intake.md" \
76
+ ".cursor/rules/core.mdc" \
77
+ ".cursor/hooks.json" \
78
+ ".cursor/scratchpad.md" \
79
+ "docs/engineering/runbook.md"; do
80
+ if [ -f "$TEST_DIR/$f" ]; then
81
+ echo "PASS: $f"
82
+ else
83
+ echo "FAIL: $f"
84
+ FAIL=1
85
+ fi
86
+ done
87
+ rm -rf "$TEST_DIR"
88
+ exit $FAIL
89
+ - name: Cleanup
90
+ if: always()
91
+ run: npm uninstall -g its-magic || true
92
+
93
+ # ── Homebrew formula test (macOS) ──────────────────────────────────
94
+ brew-test:
95
+ runs-on: macos-latest
96
+ steps:
97
+ - uses: actions/checkout@v4
98
+ - name: Validate formula syntax
99
+ run: brew style packaging/homebrew/its-magic.rb || true
100
+ - name: Test installer.sh
101
+ run: |
102
+ TEST_DIR=$(mktemp -d)
103
+ sh installer.sh --target "$TEST_DIR" --mode missing --create
104
+ FAIL=0
105
+ for f in \
106
+ ".cursor/commands/intake.md" \
107
+ ".cursor/rules/core.mdc" \
108
+ ".cursor/hooks.json" \
109
+ ".cursor/scratchpad.md" \
110
+ "docs/engineering/runbook.md"; do
111
+ if [ -f "$TEST_DIR/$f" ]; then
112
+ echo "PASS: $f"
113
+ else
114
+ echo "FAIL: $f"
115
+ FAIL=1
116
+ fi
117
+ done
118
+ rm -rf "$TEST_DIR"
119
+ exit $FAIL
120
+
121
+ # ── Chocolatey package test (Windows) ──────────────────────────────
122
+ choco-test:
123
+ runs-on: windows-latest
124
+ steps:
125
+ - uses: actions/checkout@v4
126
+ - name: Validate choco pack
127
+ shell: powershell
128
+ run: |
129
+ Push-Location packaging/chocolatey
130
+ choco pack
131
+ $nupkg = Get-ChildItem -Filter "*.nupkg" | Select-Object -First 1
132
+ if ($nupkg) {
133
+ Write-Host "PASS: Package created - $($nupkg.Name)"
134
+ } else {
135
+ Write-Host "FAIL: No .nupkg created"
136
+ exit 1
137
+ }
138
+ Pop-Location
139
+ - name: Test installer.ps1
140
+ shell: powershell
141
+ run: |
142
+ $testDir = Join-Path $env:TEMP "its-magic-ci-test"
143
+ & .\installer.ps1 -Target $testDir -Mode missing -Create
144
+ $fail = 0
145
+ $files = @(
146
+ ".cursor\commands\intake.md",
147
+ ".cursor\rules\core.mdc",
148
+ ".cursor\hooks.json",
149
+ ".cursor\scratchpad.md",
150
+ "docs\engineering\runbook.md"
151
+ )
152
+ foreach ($f in $files) {
153
+ $fp = Join-Path $testDir $f
154
+ if (Test-Path $fp) {
155
+ Write-Host "PASS: $f"
156
+ } else {
157
+ Write-Host "FAIL: $f"
158
+ $fail = 1
159
+ }
160
+ }
161
+ Remove-Item -Recurse -Force $testDir
162
+ exit $fail
163
+