@corners/cli 0.0.5 → 0.0.7

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.
@@ -0,0 +1,245 @@
1
+ ---
2
+ name: corners-sync
3
+ version: 0.1.0
4
+ description: |
5
+ Pull workstream context and present a structured briefing.
6
+ Shows recent activity, open questions, and suggested next actions.
7
+ Offers to answer open questions inline and writes context to memory.
8
+ allowed-tools:
9
+ - Bash
10
+ - Read
11
+ - Write
12
+ - AskUserQuestion
13
+ ---
14
+
15
+ # /corners-sync — "Get me up to speed"
16
+
17
+ Pull context from your connected workstream, present a structured briefing,
18
+ answer open questions inline, and write key context to memory for future sessions.
19
+
20
+ ---
21
+
22
+ ## Step 0: Preamble
23
+
24
+ Run these commands to check auth and resolve context:
25
+
26
+ ```bash
27
+ corners auth status --json 2>/dev/null || echo "CORNERS_CLI_MISSING"
28
+ ```
29
+
30
+ ```bash
31
+ corners workstream current --json 2>/dev/null
32
+ ```
33
+
34
+ ```bash
35
+ _BRANCH=$(git branch --show-current 2>/dev/null || echo "unknown")
36
+ echo "BRANCH: $_BRANCH"
37
+ git log --oneline -5 2>/dev/null
38
+ git status --short 2>/dev/null | head -10
39
+ ```
40
+
41
+ **Error handling — check in this order:**
42
+
43
+ 1. If the first command printed `CORNERS_CLI_MISSING` or `command not found`: tell the user
44
+ "Corners CLI is not installed. Run `npm install -g @corners/cli` to install it." and **STOP**.
45
+
46
+ 2. Parse the auth status JSON. If `loggedIn` is `false` OR `remoteValid` is `false`:
47
+ tell the user "Your Corners session has expired. Run `corners auth login` to re-authenticate." and **STOP**.
48
+
49
+ 3. Parse the workstream current JSON. If `resolvedCorner` is null or missing:
50
+ tell the user "No corner is configured for this directory. Run `corners corner use <cornerId>` to set one up." and **STOP**.
51
+
52
+ 4. Check `connectedWorkstreamIds` in the workstream current JSON.
53
+ If the array is empty, proceed to Step 1 (workstream resolution).
54
+ If it has entries, skip to Step 2 using the first connected workstream ID.
55
+
56
+ ---
57
+
58
+ ## Step 1: Workstream Resolution (only if no workstream connected)
59
+
60
+ Run:
61
+ ```bash
62
+ corners workstream list --json 2>/dev/null
63
+ ```
64
+
65
+ Parse the response. There are three scenarios:
66
+
67
+ **Scenario A — Workstreams exist:**
68
+ Normalize the current git branch name: strip common prefixes (`feat/`, `fix/`, `chore/`, `refactor/`),
69
+ replace hyphens and underscores with spaces, and title-case the result.
70
+ Compare this normalized name against the `name` field of each workstream in the list.
71
+
72
+ If a workstream name is similar to the normalized branch name, use AskUserQuestion:
73
+ - Question: "Found workstream '{name}' which seems related to your branch '{branch}'. Connect it?"
74
+ - Options: "Yes, connect it" / "No, show me all workstreams" / "Create a new one instead"
75
+
76
+ If "Yes": run `corners workstream use <id> --json` and proceed to Step 2.
77
+ If "Show all": present the full list via AskUserQuestion and let the user pick.
78
+ If "Create new": proceed to Scenario C.
79
+
80
+ If no workstream name matches the branch, present the full list via AskUserQuestion
81
+ and let the user pick one, or offer to create a new one.
82
+
83
+ **Scenario B — No workstreams exist anywhere:**
84
+ Use AskUserQuestion:
85
+ - Question: "No workstreams exist yet. Create one to start tracking your work?"
86
+ - Derive a suggested name from the current branch (e.g., `feat/auth-refactor` → "Auth Refactor")
87
+ - Options: "Yes, create '{suggested name}'" / "Yes, with a different name" / "Skip — just show git context"
88
+
89
+ If creating: run `corners workstream create "{name}" --json`, then `corners workstream use <returned id> --json`.
90
+
91
+ **Scenario C — Create new:**
92
+ Derive name from branch, confirm with user, run create + use.
93
+
94
+ After resolution, proceed to Step 2 with the workstream ID.
95
+
96
+ ---
97
+
98
+ ## Step 2: Pull Workstream Context
99
+
100
+ Run these commands to gather full context:
101
+
102
+ ```bash
103
+ corners workstream pull <workstreamId> --json 2>/dev/null
104
+ ```
105
+
106
+ ```bash
107
+ corners workstream question list <workstreamId> --json 2>/dev/null
108
+ ```
109
+
110
+ Parse the JSON responses. Extract:
111
+ - From pull: `workstream.id`, `workstream.name`, `workstream.summary`, `workstream.status`,
112
+ `threads[]`, `feedEvents[]`, `attachments[]`
113
+ - From question list: `questions[]` with fields `id`, `questionText`, `rationale`,
114
+ `suggestedAnswers[]`, `askedBy`, `status`, `createdAt`
115
+
116
+ If `feedEvents` or `threads` has more than 10 items, use only the most recent 10
117
+ and note the total count.
118
+
119
+ ---
120
+
121
+ ## Step 3: Present Structured Briefing
122
+
123
+ Display the briefing in this format:
124
+
125
+ ```
126
+ ## Workstream: {name} ({id})
127
+ Status: {status}
128
+ Summary: {summary}
129
+
130
+ ### Recent Activity
131
+ {Summarize the last 10 feed events in 1-2 lines each. Include type, timestamp, and key content.}
132
+
133
+ ### Open Questions ({count})
134
+ {For each open question:}
135
+ - **{askedBy}** ({timeAgo}): "{questionText}"
136
+ Suggested answers: {list suggestedAnswers}
137
+
138
+ ### Threads ({count})
139
+ {For each thread, show topic/subject and message count}
140
+
141
+ ### Attachments ({count})
142
+ {List any linked documents, files, or artifacts}
143
+
144
+ ### Local Git State
145
+ Branch: {branch}
146
+ Recent commits: {list from git log}
147
+ Working tree: {clean / N files modified}
148
+
149
+ ### Suggested Next Actions
150
+ {Based on the context, suggest 2-3 concrete next steps. Examples:}
151
+ - Answer Alice's question about the API schema
152
+ - Review the latest thread about deployment
153
+ - Continue work on the auth-refactor branch
154
+ ```
155
+
156
+ ---
157
+
158
+ ## Step 4: Answer-at-Sync
159
+
160
+ After presenting the briefing, check if any open questions exist.
161
+
162
+ For each open question (up to 3), use AskUserQuestion:
163
+ - Re-ground: "Workstream '{name}' on branch {branch}."
164
+ - Question: "{askedBy} asked: '{questionText}'"
165
+ - If suggested answers exist, include them as options plus "Skip" and "Custom answer"
166
+ - If no suggested answers, options: "Answer now" / "Skip"
167
+
168
+ If the user provides an answer, post it:
169
+ ```bash
170
+ corners workstream question answer <questionId> --text "$(cat <<'CORNERS_MSG'
171
+ <user's answer text>
172
+ CORNERS_MSG
173
+ )" --json
174
+ ```
175
+
176
+ If the user skips, move to the next question or proceed to Step 5.
177
+
178
+ ---
179
+
180
+ ## Step 5: Memory Write
181
+
182
+ Write workstream context to Claude Code's memory system so it persists across conversations.
183
+
184
+ Determine the memory directory path. It follows the pattern:
185
+ `~/.claude/projects/-{path-with-hyphens}/memory/`
186
+
187
+ For this project, the path is derived from the working directory. Use the memory
188
+ directory that already exists for this project.
189
+
190
+ Write a memory file named `workstream_{normalized_name}.md` (lowercase, hyphens for spaces):
191
+
192
+ ```markdown
193
+ ---
194
+ name: Workstream context - {name}
195
+ description: Active workstream {name} ({id}) - {summary}
196
+ type: project
197
+ ---
198
+
199
+ Connected workstream for this repository.
200
+
201
+ - **ID:** {id}
202
+ - **Name:** {name}
203
+ - **Status:** {status}
204
+ - **Summary:** {summary}
205
+
206
+ **Open questions ({count}):**
207
+ {For each: "- {askedBy}: {questionText}" — keep to 1 line each}
208
+
209
+ **Recent activity:**
210
+ {2-3 sentence summary of what's been happening}
211
+
212
+ **How to apply:** When working in this repo, this workstream provides the coordination context. Check for open questions before starting new work. Use /corners-push to record progress.
213
+ ```
214
+
215
+ Then read the existing `MEMORY.md` file in the same directory. If a reference to this
216
+ workstream memory file doesn't already exist, add it under the `## Project` section.
217
+
218
+ ---
219
+
220
+ ## Manual Equivalent
221
+
222
+ The raw CLI commands this skill orchestrates:
223
+
224
+ ```bash
225
+ # Check auth
226
+ corners auth status --json
227
+
228
+ # Resolve local context
229
+ corners workstream current --json
230
+
231
+ # List available workstreams
232
+ corners workstream list --json
233
+
234
+ # Connect a workstream
235
+ corners workstream use <wsId>
236
+
237
+ # Pull full context
238
+ corners workstream pull <wsId> --json
239
+
240
+ # List open questions
241
+ corners workstream question list <wsId> --json
242
+
243
+ # Answer a question
244
+ corners workstream question answer <questionId> --text "..." --json
245
+ ```