@brainervirus/workit-cursor 0.6.1 → 0.7.1

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 (75) hide show
  1. package/.cursor-plugin/plugin.json +8 -5
  2. package/assets/templates/execution-contract.md +58 -0
  3. package/assets/templates/greeting.md +1 -0
  4. package/assets/templates/headers.md +3 -0
  5. package/assets/templates/hygiene/.editorconfig +8 -0
  6. package/assets/templates/hygiene/.gitattributes +3 -0
  7. package/assets/templates/hygiene/CHANGELOG.md +14 -0
  8. package/assets/templates/hygiene/CONTRIBUTING.md +3 -0
  9. package/assets/templates/hygiene/LICENSE +21 -0
  10. package/assets/templates/hygiene/README.md +3 -0
  11. package/assets/templates/issue-update.md +6 -0
  12. package/assets/templates/plan-template.md +25 -0
  13. package/assets/templates/spec-template.md +51 -0
  14. package/assets/templates/superpowers-doc-contract.md +70 -0
  15. package/dist/cursor-session-start.js +351 -0
  16. package/dist/mcp-server.js +27678 -0
  17. package/hooks/hooks-cursor.json +2 -1
  18. package/hooks/session-start +12 -43
  19. package/marketplace.json +2 -2
  20. package/mcp/run-server.sh +5 -52
  21. package/mcp.json +2 -6
  22. package/package.json +19 -7
  23. package/rules/ask-question-only.mdc +1 -1
  24. package/rules/sdd-docs-path.mdc +2 -2
  25. package/skills/wk-changelog/SKILL.md +1 -1
  26. package/skills/wk-commit/SKILL.md +1 -1
  27. package/skills/wk-docs-refresh/SKILL.md +1 -1
  28. package/skills/wk-handoff/SKILL.md +2 -2
  29. package/skills/wk-implement/SKILL.md +4 -4
  30. package/skills/wk-issue-update/SKILL.md +2 -0
  31. package/skills/wk-pr/SKILL.md +2 -0
  32. package/skills/wk-release-notes/SKILL.md +1 -1
  33. package/skills/wk-verify/SKILL.md +1 -1
  34. package/vendor/superpowers/skills/brainstorming/SKILL.md +159 -0
  35. package/vendor/superpowers/skills/brainstorming/scripts/frame-template.html +213 -0
  36. package/vendor/superpowers/skills/brainstorming/scripts/helper.js +167 -0
  37. package/vendor/superpowers/skills/brainstorming/scripts/server.cjs +723 -0
  38. package/vendor/superpowers/skills/brainstorming/spec-document-reviewer-prompt.md +49 -0
  39. package/vendor/superpowers/skills/brainstorming/visual-companion.md +222 -0
  40. package/vendor/superpowers/skills/dispatching-parallel-agents/SKILL.md +185 -0
  41. package/vendor/superpowers/skills/executing-plans/SKILL.md +70 -0
  42. package/vendor/superpowers/skills/finishing-a-development-branch/SKILL.md +241 -0
  43. package/vendor/superpowers/skills/receiving-code-review/SKILL.md +213 -0
  44. package/vendor/superpowers/skills/requesting-code-review/SKILL.md +103 -0
  45. package/vendor/superpowers/skills/requesting-code-review/code-reviewer.md +172 -0
  46. package/vendor/superpowers/skills/subagent-driven-development/SKILL.md +418 -0
  47. package/vendor/superpowers/skills/subagent-driven-development/implementer-prompt.md +139 -0
  48. package/vendor/superpowers/skills/subagent-driven-development/task-reviewer-prompt.md +188 -0
  49. package/vendor/superpowers/skills/systematic-debugging/CREATION-LOG.md +119 -0
  50. package/vendor/superpowers/skills/systematic-debugging/SKILL.md +296 -0
  51. package/vendor/superpowers/skills/systematic-debugging/condition-based-waiting-example.ts +158 -0
  52. package/vendor/superpowers/skills/systematic-debugging/condition-based-waiting.md +115 -0
  53. package/vendor/superpowers/skills/systematic-debugging/defense-in-depth.md +122 -0
  54. package/vendor/superpowers/skills/systematic-debugging/root-cause-tracing.md +169 -0
  55. package/vendor/superpowers/skills/systematic-debugging/test-academic.md +14 -0
  56. package/vendor/superpowers/skills/systematic-debugging/test-pressure-1.md +58 -0
  57. package/vendor/superpowers/skills/systematic-debugging/test-pressure-2.md +68 -0
  58. package/vendor/superpowers/skills/systematic-debugging/test-pressure-3.md +69 -0
  59. package/vendor/superpowers/skills/test-driven-development/SKILL.md +371 -0
  60. package/vendor/superpowers/skills/test-driven-development/testing-anti-patterns.md +299 -0
  61. package/vendor/superpowers/skills/using-git-worktrees/SKILL.md +202 -0
  62. package/vendor/superpowers/skills/using-superpowers/SKILL.md +62 -0
  63. package/vendor/superpowers/skills/using-superpowers/references/antigravity-tools.md +23 -0
  64. package/vendor/superpowers/skills/using-superpowers/references/codex-tools.md +39 -0
  65. package/vendor/superpowers/skills/using-superpowers/references/pi-tools.md +16 -0
  66. package/vendor/superpowers/skills/verification-before-completion/SKILL.md +139 -0
  67. package/vendor/superpowers/skills/writing-plans/SKILL.md +174 -0
  68. package/vendor/superpowers/skills/writing-plans/plan-document-reviewer-prompt.md +49 -0
  69. package/vendor/superpowers/skills/writing-skills/SKILL.md +689 -0
  70. package/vendor/superpowers/skills/writing-skills/anthropic-best-practices.md +1150 -0
  71. package/vendor/superpowers/skills/writing-skills/examples/CLAUDE_MD_TESTING.md +189 -0
  72. package/vendor/superpowers/skills/writing-skills/graphviz-conventions.dot +172 -0
  73. package/vendor/superpowers/skills/writing-skills/persuasion-principles.md +187 -0
  74. package/vendor/superpowers/skills/writing-skills/testing-skills-with-subagents.md +384 -0
  75. package/mcp/server.ts +0 -1163
@@ -2,9 +2,12 @@
2
2
  "name": "workit",
3
3
  "displayName": "Workit",
4
4
  "description": "OpenCode-style verify, PR, changelog, commit, and session handoff for Cursor",
5
- "version": "0.6.1",
6
- "skills": "../skills/",
7
- "rules": "../rules/",
8
- "mcpServers": "../mcp.json",
9
- "hooks": "../hooks/hooks-cursor.json"
5
+ "version": "0.7.1",
6
+ "skills": [
7
+ "skills/",
8
+ "vendor/superpowers/skills/"
9
+ ],
10
+ "rules": "rules/",
11
+ "mcpServers": "mcp.json",
12
+ "hooks": "hooks/hooks-cursor.json"
10
13
  }
@@ -0,0 +1,58 @@
1
+ Load `using-superpowers`, `subagent-driven-development`, `test-driven-development`, and `verification-before-completion` through OpenCode's `skill` tool. Implement the existing plan; do not re-plan.
2
+
3
+ **Spec:** <SPEC_PATH>
4
+ **Plan:** <PLAN_PATH>
5
+ **Branch:** <BRANCH>
6
+ **SDD:** `<SDD_DIR>`
7
+
8
+ ## Hard gates
9
+
10
+ - The parent is coordinator-only: it does not edit product code or perform delegated exploration.
11
+ - Never use a worktree. Branch changes are in-place through `workflow_branch_setup` on `feature/*` or `bugfix/*`; never commit on protected branches.
12
+ - Working state, briefs, ledgers, and review diffs live only under gitignored `<SDD_DIR>` in `docs/<slug>/sdd/` and use `workflow_sdd_*` tools.
13
+ - Use native `todowrite` for visible task state as well as the gitignored ledger.
14
+ - Use native `question` for branch/stash choices and guarded external mutations; call mutation tools only after approval with `confirmed: true` (grounded in the recorded NativeChoiceEvidence).
15
+ - Flow-tool confirmations are never agent-typed booleans and never caller-supplied evidence objects: on OpenCode the plugin records the user's native-`question` answer as a host-observed one-use receipt (`attested: true`, `callID`, `selectedLabel`, `recordedAt`) consumed by `workflow_spec_approve` / `workflow_plan_approve` / `workflow_plan_menu` — no evidence argument exists, and delegated worker status comes from host session parentage (`parentID`), never a caller `role` field. On Cursor, confirmations are policy-only (`attested: false`) and subagent-driven execution is rejected as unsupported.
16
+ - On Cursor, for every repository-scoped `workflow_*` call, pass the active Cursor workspace as `workspace_root`; never rely on the MCP process default.
17
+ - Use native `task` with only the built-in `explore` and `general` agents.
18
+
19
+ ## Flow gates (HARD)
20
+
21
+ - `wk-implement` refuses to run unless the plan is `approved` (flow.json) and the post-plan menu was presented.
22
+ - `wk-handoff` refuses to run unless both spec and plan are `approved`.
23
+ - Sequence is enforced by tools: `workflow_spec_approve`, `workflow_plan_approve`, `workflow_plan_menu` — never skip a step (the spec/plan self-review runs automatically inside the transition; only the final approval asks for your confirmation).
24
+
25
+ ## Setup
26
+
27
+ 0. Call `workflow_docs_validate` with the linked spec/plan paths. Hard-fail on any error before todos or branch setup.
28
+ 1. Call `workflow_sdd_context` with `<PLAN_PATH>` and initialize `todowrite` from returned tasks.
29
+ 2. Call `workflow_plan_tasks`; cache each top-level task's `section_text`.
30
+ 3. Mark IDs in `completed_task_ids` completed and never redispatch them.
31
+ 4. Call `workflow_resolve_branch`, then show the current branch, target branch, and stash behavior before any in-place checkout/setup mutation.
32
+ 5. Always use `question`: for a clean tree ask whether to proceed or cancel; for a dirty tree add the stash choice and describe what will be stashed.
33
+ 6. Call `workflow_branch_setup` with `confirmed: true` only after approval.
34
+
35
+ ## Remaining-task loop
36
+
37
+ For each top-level task absent from `completed_task_ids`:
38
+
39
+ 1. Mark it `in_progress` with `todowrite`.
40
+ 2. Create a working-state brief with `workflow_sdd_task_brief` and `confirmed: true`.
41
+ 3. Delegate read-only discovery, when needed, to an `explore` agent. Delegate implementation to a fresh `general` agent. Product changes follow TDD.
42
+ 4. Create a working-state diff with `workflow_sdd_review_package` and `confirmed: true`.
43
+ 5. Delegate spec-compliance review and code-quality review to separate `general` agents.
44
+ 6. **Blocking** findings (Critical, Important, or spec-compliance) may trigger at most **two** fix+re-review rounds per task. **Advisory** findings (Minor, style, YAGNI, taste) never pause the loop — append them to `<SDD_DIR>/advisories.md`.
45
+ 7. Append the validated ledger entry with `workflow_sdd_append_progress` and `confirmed: true`; mark the todo completed.
46
+
47
+ ## Final gate
48
+
49
+ Run a separate full-branch code review, then `workflow_verify`. Present the full `<SDD_DIR>/advisories.md` roll-up once, then use native `question` so the user can choose which advisory items to fix, discuss, or discard. Report exact check results and never infer success. Use `workflow_git_context` for a commit preview and load `wk-commit` through `skill` for an approved commit. If working state contains a stash reference, preview reapplication through `question`, then call `workflow_branch_setup` with `confirmed: true` after approval.
50
+
51
+ ## Task order
52
+
53
+ <TASK_LIST>
54
+
55
+ ## Quality gate (HARD)
56
+
57
+ - Specs/plans are written from `templates/spec-template.md` / `templates/plan-template.md`.
58
+ - After `workflow_docs_validate`, surface `quality` findings (spec scan). Hard findings (missing required section, missing CA-XX) block task start unless the user explicitly waives them. Warnings are advisory.
@@ -0,0 +1 @@
1
+ {{greetingText}}
@@ -0,0 +1,3 @@
1
+ ## Adjunto capturas
2
+
3
+ ## Archivos adjuntos
@@ -0,0 +1,8 @@
1
+ root = true
2
+
3
+ [*]
4
+ charset = utf-8
5
+ end_of_line = lf
6
+ insert_final_newline = true
7
+ indent_style = space
8
+ indent_size = 2
@@ -0,0 +1,3 @@
1
+ * text=auto
2
+ *.md text
3
+ *.bat text eol=crlf
@@ -0,0 +1,14 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ### Added
11
+
12
+ ### Changed
13
+
14
+ ### Fixed
@@ -0,0 +1,3 @@
1
+ # Contributing
2
+
3
+ <!-- How to report issues, propose changes, and the review process. -->
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) <YEAR> <HOLDER>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,3 @@
1
+ # <PROJECT>
2
+
3
+ <!-- Describe the project: what it does, how to run it, how to contribute. -->
@@ -0,0 +1,6 @@
1
+ # Actualización
2
+ {{greetingSection}}
3
+ {{projectSection}}
4
+ {{userNotesSection}}
5
+ {{progressSection}}
6
+ {{gitCommitsSection}}
@@ -0,0 +1,25 @@
1
+ # <Feature> Implementation Plan
2
+
3
+ > **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking.
4
+
5
+ **Spec:** `docs/<slug>/spec.md`
6
+ **Branch:** `feature/<slug>`
7
+
8
+ **Goal:** <one sentence>
9
+
10
+ ## Global Constraints
11
+
12
+ - <project-wide requirements, one line each>
13
+
14
+ ---
15
+
16
+ ### Task N: <Component>
17
+
18
+ - [ ] **Step 1: <action>**
19
+
20
+ <!-- per-task criteria: how this task is verified -->
21
+ **Criteria:** <verifiable check>
22
+
23
+ | Status | Task |
24
+ | --- | --- |
25
+ | pending | N: <Component> |
@@ -0,0 +1,51 @@
1
+ # Spec: <feature>
2
+
3
+ **Branch:** `feature/<slug>`
4
+
5
+ ## Context
6
+
7
+ <!-- Why does this exist? What problem does it solve? 1-3 sentences. -->
8
+
9
+ ## Goals
10
+
11
+ - <!-- measurable, one per bullet -->
12
+
13
+ ## Non-goals
14
+
15
+ - <!-- explicitly out of scope -->
16
+
17
+ ## Architecture
18
+
19
+ <!-- REQUIRED if this spec has flows or architecture: render a mermaid diagram (workflow_present_flow). -->
20
+ ```mermaid
21
+ flowchart TD
22
+ A[Start] --> B[Step]
23
+ ```
24
+
25
+ <!-- REQUIRED if this spec touches UI: render an ASCII wireframe (workflow_present_ascii). -->
26
+ ```text
27
+ ┌──────────────┐
28
+ │ Header │
29
+ └──────────────┘
30
+ ```
31
+
32
+ ## Data flow / contracts
33
+
34
+ <!-- REQUIRED when there is a glossary, scope comparison, or contracts: use markdown tables. -->
35
+ | Term | Meaning |
36
+ | --- | --- |
37
+ | <term> | <meaning> |
38
+
39
+ ## Acceptance criteria
40
+
41
+ <!-- REQUIRED: enumerable, each verifiable. Numbered CA-01, CA-02, ... -->
42
+ - CA-01 …
43
+ - CA-02 …
44
+
45
+ ## Decisions
46
+
47
+ - D-01 …
48
+
49
+ ## Future work
50
+
51
+ - …
@@ -0,0 +1,70 @@
1
+ # Superpowers document contract
2
+
3
+ Use OpenCode's native `question` for every bounded user choice. Give concise choices and allow a custom answer; if the tool is unavailable, ask one concise plain-text question. Use `skill` to load workflow and Superpowers skills, `todowrite` for task state, and `task` for delegated work.
4
+
5
+ ## Tracked document layout
6
+
7
+ | Document | Path |
8
+ | --- | --- |
9
+ | Spec | `docs/<slug>/spec.md` |
10
+ | Plan | `docs/<slug>/plan.md` |
11
+ | SDD state | `docs/<slug>/sdd/` |
12
+
13
+ An optional human mirror may live at `docs/specs/<same-basename>.md`; when present, keep its branch identical.
14
+
15
+ Specs require:
16
+
17
+ ```markdown
18
+ **Branch:** `feature/<slug>`
19
+ ```
20
+
21
+ Plans require:
22
+
23
+ ```markdown
24
+ **Spec:** `docs/<slug>/spec.md`
25
+ **Branch:** `feature/<slug>`
26
+ ```
27
+
28
+ `bugfix/<slug>` is also valid. Never use `main`, `develop`, `master`, or `prod`. Use plain backtick paths. Top-level headings are exactly `### Task N: Title`; steps use `- [ ] **Step N:** ...`; task headings never appear inside fences.
29
+
30
+ Before writing **Branch:** into a new spec or plan, call `workflow_docs_branch` and write the returned `branch` verbatim. When `action` is `keep`, use the current feature/bugfix branch. When `action` is `create_from_develop` or `create_from_base`, create the branch only through `workflow_branch_setup`; it uses the configured workspace/global target branch.
31
+
32
+ ## Execution and handoff
33
+
34
+ - Implementation uses `wk-implement` and subagent-driven development, with native `todowrite` and `task`.
35
+ - Commits use `wk-commit` after its native `question` confirmation.
36
+ - Continuation uses `wk-handoff`, whose `workflow_handoff_session` creates and seeds the OpenCode session automatically.
37
+ - Never use worktrees. Resolve the declared branch with `workflow_resolve_branch`, preview dirty-tree stash choices with `question`, and apply an approved in-place checkout through `workflow_branch_setup` with `confirmed: true` (grounded in the recorded NativeChoiceEvidence).
38
+ - Flow-tool confirmations are never agent-typed booleans and never caller-supplied evidence objects: on OpenCode the plugin records the user's native-`question` answer as a host-observed one-use receipt (`attested: true`, `callID`, `selectedLabel`, `recordedAt`) consumed by `workflow_spec_approve` / `workflow_plan_approve` / `workflow_plan_menu` — no evidence argument exists, and delegated worker status comes from host session parentage (`parentID`), never a caller `role` field. On Cursor, confirmations are policy-only (`attested: false`) and subagent-driven execution is rejected as unsupported.
39
+ - Keep all SDD state under the gitignored `docs/<slug>/sdd/`; use `workflow_sdd_context` and the registered `workflow_sdd_*` tools.
40
+ - After implementation, use `question` before an approved stash reapply through `workflow_branch_setup` with `confirmed: true`.
41
+
42
+ ## YouTrack content
43
+
44
+ Chat follows the user's language. YouTrack task comments are Spanish (`es-CL`) and use `workflow_youtrack_draft` followed by reviewed `workflow_youtrack_post` with `confirmed: true`. Preserve the user's paragraph voice; do not inject commits, file paths, or robotic bullet reports.
45
+
46
+ ## Final self-check
47
+
48
+ Before handoff, call `workflow_docs_validate` on the linked spec/plan pair. Hard-fail on any error; never offer execution when validation fails.
49
+
50
+ Before handoff, verify the saved spec path, plan path, declared branch, top-level task numbering, and workflow-managed SDD directory through the registered read-only workflow tools. Report structured failures; never infer success.
51
+
52
+ ## Post-plan execution choice
53
+
54
+ After saving a plan, call `workflow_docs_validate` on the spec/plan pair. On failure, stop and fix docs — do not offer execution.
55
+
56
+ On success, use native `question` / Cursor `AskQuestion` with exactly these options (no stay, no A/B/C prose duplicate):
57
+
58
+ 1. Subagent-driven → load `wk-implement`
59
+ 2. Inline → execute in this session
60
+ 3. Handoff → load `wk-handoff` (new session only)
61
+ 4. Review spec first
62
+ 5. Review plan first
63
+
64
+ Never emit Superpowers text beginning “Two execution options”.
65
+
66
+ - Specs/plans must follow `templates/spec-template.md` / `templates/plan-template.md` (mandated diagrams, tables, CA-XX).
67
+
68
+ ## Doc delivery
69
+
70
+ When delivering a spec or plan, use a clickable markdown link (\`[spec.md](docs/<slug>/spec.md)\`) and a 3-5 bullet summary of the content (Context, Goals, key decisions, status). Never reference docs with backtick-only paths.
@@ -0,0 +1,351 @@
1
+ #!/usr/bin/env node
2
+
3
+ // packages/workit-cursor/hooks/session-start.ts
4
+ import { existsSync, readFileSync } from "node:fs";
5
+ import path2 from "node:path";
6
+ import { fileURLToPath } from "node:url";
7
+
8
+ // packages/workit-core/src/core/logger.ts
9
+ import { appendFileSync, mkdirSync, readdirSync, unlinkSync } from "node:fs";
10
+ import os from "node:os";
11
+ import path from "node:path";
12
+ var REDACTED = "[REDACTED]";
13
+ var DEFAULT_MAX_RATE = 20;
14
+ var DEFAULT_RATE_WINDOW_MS = 1000;
15
+ var DEFAULT_MAX_FIELD_LENGTH = 200;
16
+ var DEFAULT_MAX_STACK_LINES = 30;
17
+ var DAY_FILE = /^workit-\d{4}-\d{2}-\d{2}\.jsonl$/;
18
+ var RETAINED_DAYS = 7;
19
+ var SECRET_VALUE = /\b(?:Bearer|Basic|Digest|Token)\s+\S+/gi;
20
+ var KEY_EQ_VALUE = /\b([A-Za-z0-9_-]*(?:token|secret|password|passwd|apikey|api[_-]?key|authorization|credential|bearer)[A-Za-z0-9_-]*)([:=]\s*).+/gi;
21
+ var URL_QUERY = /(https?:\/\/[^?#\s]+)\?[^#\s]*/g;
22
+ var splitKey = (key) => key.split(/[_-]+|(?<=[a-z0-9])(?=[A-Z])|(?<=[A-Z])(?=[A-Z][a-z])/).map((word) => word.toLowerCase());
23
+ var SENSITIVE_WORDS = new Set([
24
+ "token",
25
+ "secret",
26
+ "password",
27
+ "passwd",
28
+ "authorization",
29
+ "credential",
30
+ "credentials",
31
+ "cookie",
32
+ "api",
33
+ "apikey",
34
+ "apitoken",
35
+ "accesstoken",
36
+ "clientsecret",
37
+ "refreshtoken",
38
+ "key",
39
+ "bearer",
40
+ "prompt",
41
+ "message",
42
+ "messages",
43
+ "content",
44
+ "body",
45
+ "args",
46
+ "argument",
47
+ "result",
48
+ "results",
49
+ "output",
50
+ "issue",
51
+ "description",
52
+ "summary",
53
+ "payload",
54
+ "script",
55
+ "command",
56
+ "text",
57
+ "query"
58
+ ]);
59
+ var STACK_WORDS = new Set(["stack", "stacktrace", "trace"]);
60
+ var escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
61
+ var resolveStateDir = () => {
62
+ const override = process.env.WORKFLOW_TOOLKIT_STATE;
63
+ if (override)
64
+ return override;
65
+ const home = os.homedir();
66
+ if (process.env.XDG_STATE_HOME)
67
+ return path.join(process.env.XDG_STATE_HOME, "workit");
68
+ switch (os.platform()) {
69
+ case "darwin":
70
+ return path.join(home, "Library", "Application Support", "workit");
71
+ case "win32":
72
+ return path.join(process.env.LOCALAPPDATA ?? path.join(home, "AppData", "Local"), "workit");
73
+ default:
74
+ return path.join(process.env.HOME ?? home, ".local", "state", "workit");
75
+ }
76
+ };
77
+ var homePattern = new RegExp(`${escapeRegExp(os.homedir())}(?=[/\\\\]|$)|\\$HOME(?=[/\\\\]|$)`, "g");
78
+ var applyPatterns = (value) => {
79
+ let out = value;
80
+ out = out.replace(SECRET_VALUE, REDACTED);
81
+ out = out.replace(KEY_EQ_VALUE, "$1$2[REDACTED]");
82
+ out = out.replace(URL_QUERY, "$1?[REDACTED]");
83
+ out = out.replace(homePattern, "~");
84
+ if (process.platform === "win32")
85
+ out = out.replace(/\\/g, "/");
86
+ return out;
87
+ };
88
+ var redactString = (value, options) => {
89
+ const out = applyPatterns(value);
90
+ if (out.length > options.maxFieldLength) {
91
+ return `${out.slice(0, options.maxFieldLength)}…`;
92
+ }
93
+ return out;
94
+ };
95
+ var boundStack = (value, options) => {
96
+ if (typeof value !== "string")
97
+ return redact(value, options);
98
+ const lines = value.split(`
99
+ `);
100
+ const kept = lines.slice(0, options.maxStackLines).map(applyPatterns);
101
+ const dropped = lines.length - kept.length;
102
+ const body = dropped > 0 ? [...kept, ` ... ${dropped} more`] : kept;
103
+ return body.join(`
104
+ `);
105
+ };
106
+ var redact = (value, options = DEFAULT_OPTIONS) => {
107
+ if (value === null || value === undefined)
108
+ return null;
109
+ if (typeof value === "boolean" || typeof value === "number")
110
+ return value;
111
+ if (typeof value === "string")
112
+ return redactString(value, options);
113
+ if (value instanceof Date)
114
+ return value.toISOString();
115
+ if (Array.isArray(value))
116
+ return value.map((entry) => redact(entry, options));
117
+ if (typeof value === "object") {
118
+ const out = {};
119
+ for (const [key, entry] of Object.entries(value)) {
120
+ const words = splitKey(key);
121
+ if (words.some((word) => STACK_WORDS.has(word)))
122
+ out[key] = boundStack(entry, options);
123
+ else if (words.some((word) => SENSITIVE_WORDS.has(word)))
124
+ out[key] = REDACTED;
125
+ else
126
+ out[key] = redact(entry, options);
127
+ }
128
+ return out;
129
+ }
130
+ return null;
131
+ };
132
+ var DEFAULT_OPTIONS = {
133
+ maxFieldLength: DEFAULT_MAX_FIELD_LENGTH,
134
+ maxStackLines: DEFAULT_MAX_STACK_LINES
135
+ };
136
+ var dailyFileName = (date) => {
137
+ const y = date.getFullYear();
138
+ const m = String(date.getMonth() + 1).padStart(2, "0");
139
+ const d = String(date.getDate()).padStart(2, "0");
140
+ return `workit-${y}-${m}-${d}.jsonl`;
141
+ };
142
+ var pruneOldFiles = (dir) => {
143
+ try {
144
+ const files = readdirSync(dir).filter((name) => DAY_FILE.test(name)).sort().reverse();
145
+ for (const file of files.slice(RETAINED_DAYS)) {
146
+ try {
147
+ unlinkSync(path.join(dir, file));
148
+ } catch {}
149
+ }
150
+ } catch {}
151
+ };
152
+ var createLogger = (options = {}) => {
153
+ const stateDir = options.stateDir ?? resolveStateDir();
154
+ const logDir = path.join(stateDir, "logs");
155
+ const now = options.now ?? (() => new Date);
156
+ const maxRate = options.maxRate ?? DEFAULT_MAX_RATE;
157
+ const rateWindowMs = options.rateWindowMs ?? DEFAULT_RATE_WINDOW_MS;
158
+ const redactOptions = {
159
+ maxFieldLength: options.maxFieldLength ?? DEFAULT_MAX_FIELD_LENGTH,
160
+ maxStackLines: options.maxStackLines ?? DEFAULT_MAX_STACK_LINES
161
+ };
162
+ let windowStart = 0;
163
+ const windowCounts = { debug: 0, info: 0, warn: 0, error: 0 };
164
+ const emit = (level, message, context) => {
165
+ const date = now();
166
+ const elapsed = date.getTime() - windowStart;
167
+ if (elapsed >= rateWindowMs || windowStart === 0) {
168
+ windowStart = date.getTime();
169
+ windowCounts.debug = 0;
170
+ windowCounts.info = 0;
171
+ windowCounts.warn = 0;
172
+ windowCounts.error = 0;
173
+ }
174
+ windowCounts[level] += 1;
175
+ if (windowCounts[level] > maxRate)
176
+ return;
177
+ let event = null;
178
+ try {
179
+ event = {
180
+ level,
181
+ time: date.toISOString(),
182
+ message: redactString(message, redactOptions),
183
+ context: redact(context ?? {}, redactOptions)
184
+ };
185
+ const line = `${JSON.stringify(event)}
186
+ `;
187
+ mkdirSync(logDir, { recursive: true, mode: 448 });
188
+ appendFileSync(path.join(logDir, dailyFileName(date)), line, { mode: 384 });
189
+ pruneOldFiles(logDir);
190
+ } catch {
191
+ try {
192
+ event = {
193
+ level,
194
+ time: date.toISOString(),
195
+ message: redactString(message, redactOptions),
196
+ context: { redaction_failed: true }
197
+ };
198
+ mkdirSync(logDir, { recursive: true, mode: 448 });
199
+ appendFileSync(path.join(logDir, dailyFileName(date)), `${JSON.stringify(event)}
200
+ `, {
201
+ mode: 384
202
+ });
203
+ } catch {}
204
+ }
205
+ for (const sink of [options.appLog, options.stderr]) {
206
+ if (!sink)
207
+ continue;
208
+ if (!event)
209
+ continue;
210
+ try {
211
+ sink(event);
212
+ } catch {}
213
+ }
214
+ };
215
+ return {
216
+ debug: (message, context) => emit("debug", message, context),
217
+ info: (message, context) => emit("info", message, context),
218
+ warn: (message, context) => emit("warn", message, context),
219
+ error: (message, context) => emit("error", message, context),
220
+ guard: (name, fn) => {
221
+ try {
222
+ return fn();
223
+ } catch (err) {
224
+ emit("warn", "detector_failed", {
225
+ detector: name,
226
+ error: err instanceof Error ? err.message : String(err)
227
+ });
228
+ return;
229
+ }
230
+ }
231
+ };
232
+ };
233
+
234
+ // packages/workit-core/src/core/boundary.ts
235
+ var EVENT = {
236
+ initialization: "initialization",
237
+ provenance: "provenance",
238
+ assets: "assets",
239
+ configurationSource: "configuration_source",
240
+ hooks: "hooks",
241
+ mcpConnection: "mcp_connection",
242
+ migration: "migration",
243
+ installSteps: "install_steps",
244
+ uncaughtFailure: "uncaught_failure",
245
+ toolsFailed: "tools_failed",
246
+ doctor: "doctor"
247
+ };
248
+ var errorDetail = (err) => {
249
+ if (err instanceof Error) {
250
+ return { error_name: err.name, error: err.message };
251
+ }
252
+ return { error_name: "unknown", error: String(err) };
253
+ };
254
+
255
+ // packages/workit-core/src/core/config.ts
256
+ var diagnosticLogger;
257
+ var setDiagnosticLogger = (logger) => {
258
+ diagnosticLogger = logger;
259
+ };
260
+ var PRESETS = {
261
+ gitflow: {
262
+ allowed: ["feature/*", "bugfix/*", "hotfix/*", "release/*"],
263
+ protected: ["main", "develop", "master", "prod", "production"]
264
+ },
265
+ "github-flow": { allowed: ["*"], protected: ["main"] },
266
+ "trunk-based": { allowed: ["*"], protected: ["main"] },
267
+ custom: { allowed: [], protected: [] }
268
+ };
269
+ var DEFAULTS = {
270
+ locale: "en",
271
+ localeOptions: ["en", "es-CL", "es-MX", "es-AR", "pt-BR"],
272
+ timezone: "America/Santiago",
273
+ branchPolicy: {
274
+ preset: "gitflow",
275
+ allowed: [...PRESETS.gitflow.allowed],
276
+ protected: [...PRESETS.gitflow.protected]
277
+ }
278
+ };
279
+
280
+ // packages/workit-cursor/hooks/session-start.ts
281
+ var logger = createLogger({
282
+ stderr: (event) => process.stderr.write(`${JSON.stringify(event)}
283
+ `)
284
+ });
285
+ var hookDir = path2.dirname(fileURLToPath(import.meta.url));
286
+ var pluginDir = path2.resolve(hookDir, "..");
287
+ var marker = path2.join(pluginDir, ".workflow-toolkit-root");
288
+ setDiagnosticLogger(logger);
289
+ logger.info(EVENT.initialization, { host: "cursor-hook", hook_dir: hookDir });
290
+ var resolveRepoRoot = () => {
291
+ if (process.env.WORKFLOW_TOOLKIT_ROOT && existsSync(path2.join(process.env.WORKFLOW_TOOLKIT_ROOT, "templates"))) {
292
+ return process.env.WORKFLOW_TOOLKIT_ROOT;
293
+ }
294
+ if (existsSync(marker)) {
295
+ return readFileSync(marker, "utf8").replace(/\n+$/, "");
296
+ }
297
+ const ownAssets = path2.join(pluginDir, "assets");
298
+ if (existsSync(path2.join(ownAssets, "templates"))) {
299
+ return ownAssets;
300
+ }
301
+ return path2.resolve(hookDir, "../../workit-core");
302
+ };
303
+ var body = null;
304
+ var repoRoot = resolveRepoRoot();
305
+ try {
306
+ const contract = path2.join(repoRoot, "templates", "superpowers-doc-contract.md");
307
+ if (existsSync(contract))
308
+ body = readFileSync(contract, "utf8");
309
+ } catch (err) {
310
+ logger.error(EVENT.hooks, { boundary: "session-start", root: repoRoot, ...errorDetail(err) });
311
+ body = null;
312
+ }
313
+ if (body === null) {
314
+ process.stdout.write(`{}
315
+ `);
316
+ process.exit(0);
317
+ }
318
+ var context = `<workflow-toolkit-askquestion-hard-gate>
319
+ HARD-GATE: Any user choice with options → call Cursor AskQuestion directly with workflow-specific copy. NEVER A/B/C in chat. Overrides Superpowers brainstorming conversational options.
320
+ </workflow-toolkit-askquestion-hard-gate>
321
+
322
+ <workflow-toolkit-visual-companion>
323
+ HARD-GATE: NEVER offer Superpowers visual companion or open a browser tab. For UI wireframes use workflow_present_ascii; for flows use workflow_present_flow. Overrides Superpowers brainstorming visual companion offer.
324
+ </workflow-toolkit-visual-companion>
325
+
326
+ <workflow-toolkit-no-worktrees>
327
+ HARD-GATE: NEVER using-git-worktrees or git worktree. In-place feature/* or bugfix/* checkout only via workflow_resolve_branch + workflow_branch_setup. Dirty tree → native AskQuestion before checkout.
328
+ </workflow-toolkit-no-worktrees>
329
+
330
+ <workflow-toolkit-sdd-path>
331
+ HARD-GATE: NEVER .superpowers/sdd. ALWAYS workflow_sdd_context with plan_path first — resolves canonical docs/<slug>/sdd/ and creates nothing (no empty ledger; progress.md appears only on the first confirmed append). workflow_sdd_task_brief, workflow_sdd_review_package, workflow_sdd_append_progress only.
332
+ </workflow-toolkit-sdd-path>
333
+
334
+ <workflow-toolkit-todowrite>
335
+ HARD-GATE: After workflow_sdd_context, call Cursor TodoWrite with returned todos (merge: false). SDD ledger is persistence — TodoWrite is the native task list UI. Keep in_progress/completed in sync each task.
336
+ </workflow-toolkit-todowrite>
337
+
338
+ <workflow-toolkit-superpowers-doc-contract>
339
+ ${body}
340
+ </workflow-toolkit-superpowers-doc-contract>
341
+
342
+ <workflow-toolkit-reminder>
343
+ HARD-GATE: Bounded user choices → call Cursor AskQuestion directly (never A/B/C or 1/2/3 lists in prose). After a plan is approved → AskQuestion menu with: Subagent-driven, Inline, Handoff (new session only), Review spec first, Review plan first. Tools with confirmed → call them; never fabricate results.
344
+ Delivering docs → clickable markdown link (docs/<slug>/spec.md) + 3-5 bullet summary.
345
+ </workflow-toolkit-reminder>`;
346
+ process.stdout.write(JSON.stringify({ additional_context: context }, null, 2) + `
347
+ `);
348
+ process.exit(0);
349
+ export {
350
+ logger
351
+ };