-
Notifications
You must be signed in to change notification settings - Fork 0
feat(unic-spec-review): self-contained auth and preflight (/setup-confluence, /spec-doctor) #211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
orioltf
merged 4 commits into
develop
from
archon/task-feature-unic-spec-review-203-setup-confluence-spec
Jun 5, 2026
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
d8122cd
feat(unic-spec-review): self-contained auth and preflight (/setup-con…
orioltf ce92234
fix(unic-spec-review): address PR #211 review findings
orioltf 8c4673b
fix(unic-spec-review): remove em dashes from authored text (PR #211)
orioltf a8dcc5b
fix(unic-spec-review): address PR #211 multi-agent review findings
orioltf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 48 additions & 4 deletions
52
apps/claude-code/unic-spec-review/commands/setup-confluence.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,53 @@ | ||
| --- | ||
| description: Interactive setup wizard that writes Confluence credentials to ~/.unic-confluence.json for unic-spec-review. | ||
| allowed-tools: Bash(node *), Bash(test *), Bash(echo *) | ||
| argument-hint: (no arguments) | ||
| description: Interactive setup wizard - writes ~/.unic-confluence.json with Confluence credentials | ||
| --- | ||
|
|
||
| # Setup Confluence | ||
| # unic-spec-review:setup-confluence | ||
|
|
||
| > ⚠️ Scaffold stub: not yet implemented. Behaviour is specified in the [PRD](../docs/issues/unic-spec-review/PRD.md) (#200); the command body lands with its implementation slice. | ||
| Guides you through creating `~/.unic-confluence.json` so the plugin can reach Confluence. | ||
|
|
||
| This plugin ships its own Confluence credential wizard so it is fully self-contained: it never depends on another plugin being installed or set up. It writes to the shared `~/.unic-confluence.json` convention (also honouring `CONFLUENCE_*` env vars), so a user with `unic-pr-review` already configured does not configure Confluence twice. See `AGENTS.md` for the locked design. | ||
| ## Step 1 - Check for existing env-var configuration | ||
|
|
||
| If `CONFLUENCE_URL`, `CONFLUENCE_USER`, and `CONFLUENCE_TOKEN` are all set, the file is not required. | ||
| Tell the user and offer to exit without writing. If they want to write the file anyway, continue. | ||
|
|
||
| ## Step 2 - Check for an existing credential file | ||
|
|
||
| ```sh | ||
| test -f ~/.unic-confluence.json && echo "exists" | ||
| ``` | ||
|
|
||
| If the file exists, show the current values (redact the token - print only `****`): | ||
|
|
||
| ```sh | ||
| node -e " | ||
| const c = JSON.parse(require('fs').readFileSync(require('os').homedir() + '/.unic-confluence.json', 'utf8')); | ||
| console.log(JSON.stringify({ url: c.url, username: c.username, token: '****', jiraUrl: c.jiraUrl ?? null }, null, 2)); | ||
| " | ||
| ``` | ||
|
|
||
| Ask whether to overwrite. If the user chooses not to overwrite, stop. | ||
|
|
||
| ## Step 3 - Collect credentials | ||
|
|
||
| Ask the user for: | ||
|
|
||
| 1. **Confluence base URL** - e.g. `https://your-org.atlassian.net` | ||
| 2. **Username** - typically the Atlassian account email address | ||
| 3. **API token** - generate one at <https://id.atlassian.com/manage-profile/security/api-tokens> | ||
|
|
||
| ## Step 4 - Write the credential file | ||
|
|
||
| ```sh | ||
| node "${CLAUDE_PLUGIN_ROOT}/scripts/setup-confluence.mjs" --url "<url>" --username "<username>" --token "<token>" | ||
| ``` | ||
|
|
||
| ## Step 5 - Confirm | ||
|
|
||
| Tell the user: | ||
|
|
||
| - `~/.unic-confluence.json` has been written with access restricted to the owner (chmod 600) on macOS/Linux | ||
| - On Windows: file permissions must be restricted manually (the wizard printed a reminder) | ||
| - They can run `/unic-spec-review:spec-doctor` to verify the full setup |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,9 +1,81 @@ | ||
| --- | ||
| allowed-tools: Bash(node *) | ||
| argument-hint: (no arguments) | ||
| description: Verify unic-spec-review prerequisites (Confluence credentials, Figma Dev Mode MCP, and Playwright MCP). | ||
| --- | ||
|
|
||
| # Spec Doctor | ||
| # unic-spec-review:spec-doctor | ||
|
|
||
| > ⚠️ Scaffold stub: not yet implemented. Behaviour is specified in the [PRD](../docs/issues/unic-spec-review/PRD.md) (#200); the command body lands with its implementation slice. | ||
| Runs a preflight check for all unic-spec-review prerequisites so you can diagnose setup issues before running a review. | ||
|
|
||
| This preflight command will check that Confluence credentials (`~/.unic-confluence.json`), the Figma Dev Mode MCP, and the Playwright MCP are present and reachable before a review. See `AGENTS.md` for the locked design. | ||
| Checks performed: | ||
|
|
||
| 1. Atlassian credentials are present (`~/.unic-confluence.json` or `CONFLUENCE_*` env vars) | ||
| 2. Confluence is reachable via HTTP (Basic auth) | ||
| 3. Figma Dev Mode MCP is connected | ||
| 4. Playwright MCP is connected | ||
|
|
||
| ## Step 1 - Print the spec-doctor header | ||
|
|
||
| Print: | ||
|
|
||
| ``` | ||
| unic-spec-review spec-doctor | ||
| ───────────────────────────────── | ||
| ``` | ||
|
|
||
| ## Step 2 - Run the Confluence credential and connectivity check | ||
|
|
||
| ```sh | ||
| node "${CLAUDE_PLUGIN_ROOT}/scripts/spec-doctor.mjs" | ||
| ``` | ||
|
|
||
| Show the script output verbatim (one ✓/✗ line per check). | ||
|
|
||
| Record whether the script exited 0 (all credential/connectivity checks passed) or 1 (failed). | ||
|
|
||
| ## Step 3 - Check for Figma Dev Mode MCP | ||
|
|
||
| Determine whether a Figma Dev Mode MCP tool is available in the current Claude Code session | ||
| by checking the active tool set for tools whose names match `mcp__figma*` or any tool clearly | ||
| from a Figma Dev Mode MCP server. | ||
|
|
||
| - If the Figma Dev Mode MCP is **available**: print `✓ Figma Dev Mode MCP - connected` | ||
| - If the Figma Dev Mode MCP is **NOT available**: print the following explicit failure (not a silent skip): | ||
| ``` | ||
| ✗ Figma Dev Mode MCP - not connected | ||
| Remediation: Enable the Figma Dev Mode MCP in your Claude Code MCP settings. | ||
| See https://help.figma.com/hc/en-us/articles/32132100888087 for setup instructions. | ||
| ``` | ||
| Record whether this check passed or failed. | ||
|
|
||
| ## Step 4 - Check for Playwright MCP | ||
|
|
||
| Determine whether a Playwright MCP tool is available in the current Claude Code session | ||
| by checking the active tool set for tools whose names match `mcp__playwright*` or any tool | ||
| clearly from a Playwright MCP server. | ||
|
|
||
| - If the Playwright MCP is **available**: print `✓ Playwright MCP - connected` | ||
| - If the Playwright MCP is **NOT available**: print the following explicit failure (not a silent skip): | ||
| ``` | ||
| ✗ Playwright MCP - not connected | ||
| Remediation: Enable the Playwright MCP in your Claude Code MCP settings. | ||
| Example config: https://github.com/microsoft/playwright-mcp | ||
| ``` | ||
| Record whether this check passed or failed. | ||
|
|
||
| ## Step 5 - Print overall result | ||
|
|
||
| Print: | ||
|
|
||
| ``` | ||
| ───────────────────────────────── | ||
| ``` | ||
|
|
||
| Then: | ||
|
|
||
| - If **all checks passed**: print `All checks passed.` | ||
| - If **any check failed**: print `One or more checks failed - see lines marked ✗ above.` | ||
|
|
||
| Missing MCPs are hard failures. Do not summarise them as warnings or caveats; | ||
| they must appear as ✗ lines. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
apps/claude-code/unic-spec-review/scripts/setup-confluence.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,119 @@ | ||
| #!/usr/bin/env node | ||
| // SPDX-License-Identifier: LGPL-3.0-or-later | ||
| // @ts-check | ||
| // Copyright © 2026 Unic | ||
|
|
||
| /** | ||
| * setup-confluence.mjs - write ~/.unic-confluence.json with the user's | ||
| * Confluence credentials. Pure file-writer: values arrive as CLI args; the | ||
| * conversational prompting happens in commands/setup-confluence.md. | ||
| */ | ||
|
|
||
| import { | ||
| chmodSync as realChmod, | ||
| existsSync as realExistsSync, | ||
| readFileSync as realReadFile, | ||
| renameSync as realRename, | ||
| writeFileSync as realWriteFile, | ||
| } from 'node:fs' | ||
| import os from 'node:os' | ||
| import { join } from 'node:path' | ||
| import { pathToFileURL } from 'node:url' | ||
| import { parseArgs } from './lib/args.mjs' | ||
|
|
||
| /** | ||
| * @typedef {Object} WriteDeps | ||
| * @property {string} [homedir] | ||
| * @property {string} [platform] | ||
| * @property {(path: string) => boolean} [exists] | ||
| * @property {(path: string, encoding: BufferEncoding) => string} [readFile] | ||
| * @property {(path: string, data: string, encoding: BufferEncoding) => void} [writeFile] | ||
| * @property {(oldPath: string, newPath: string) => void} [rename] | ||
| * @property {(path: string, mode: number) => void} [chmod] | ||
| * @property {(message: string) => void} [warn] | ||
| */ | ||
|
|
||
| /** | ||
| * Write ~/.unic-confluence.json with the given credentials. Preserves any | ||
| * existing fields (such as a `jiraUrl` written by another tool that shares | ||
| * ~/.unic-confluence.json) so re-running to rotate a token does not silently | ||
| * drop data. If the existing file is unparseable | ||
| * the writer warns and overwrites; non-syntax read errors (EACCES, etc.) | ||
| * propagate so callers can surface them rather than silently losing data. | ||
| * | ||
| * @param {string} url | ||
| * @param {string} username | ||
| * @param {string} token | ||
| * @param {WriteDeps} [deps] | ||
| * @returns {{ path: string }} | ||
| */ | ||
| export function writeConfluenceCreds(url, username, token, deps = {}) { | ||
| const home = deps.homedir ?? os.homedir() | ||
| if (!home) throw new Error('could not determine home directory (HOME / USERPROFILE unset)') | ||
| const platform = deps.platform ?? process.platform | ||
| const exists = deps.exists ?? realExistsSync | ||
| const read = deps.readFile ?? realReadFile | ||
| const write = deps.writeFile ?? realWriteFile | ||
| const rename = deps.rename ?? realRename | ||
| const chmod = deps.chmod ?? realChmod | ||
| const warn = deps.warn ?? ((m) => process.stderr.write(`${m}\n`)) | ||
|
|
||
| const path = join(home, '.unic-confluence.json') | ||
| let preserved = {} | ||
| if (exists(path)) { | ||
| const raw = read(path, 'utf8') | ||
| try { | ||
| const existing = JSON.parse(raw) | ||
| if (existing && typeof existing === 'object') preserved = existing | ||
| } catch (err) { | ||
| if (!(err instanceof SyntaxError)) throw err | ||
| warn(`${path} contains invalid JSON - overwriting (any prior jiraUrl will be lost).`) | ||
| } | ||
| } | ||
| const payload = { ...preserved, url, username, token } | ||
| const tmp = `${path}.tmp` | ||
| write(tmp, JSON.stringify(payload, null, 2), 'utf8') | ||
| if (platform === 'win32') { | ||
| warn( | ||
| `Windows detected - skipping chmod 600 on ${path}. Restrict file access manually, e.g.:\n icacls "${path}" /inheritance:r /grant:r "%USERNAME%:F"` | ||
| ) | ||
| } else { | ||
|
orioltf marked this conversation as resolved.
|
||
| chmod(tmp, 0o600) | ||
| } | ||
| rename(tmp, path) | ||
| return { path } | ||
| } | ||
|
|
||
| /** | ||
| * True when CONFLUENCE_URL, CONFLUENCE_USER and CONFLUENCE_TOKEN are all set. | ||
| * | ||
| * @param {Record<string, string | undefined>} env | ||
| * @returns {boolean} | ||
| */ | ||
| export function isEnvConfigured(env) { | ||
| return Boolean(env.CONFLUENCE_URL && env.CONFLUENCE_USER && env.CONFLUENCE_TOKEN) | ||
| } | ||
|
|
||
| async function main() { | ||
| let args | ||
| try { | ||
| args = parseArgs(process.argv.slice(2)) | ||
| } catch (err) { | ||
| process.stderr.write(`setup-confluence: ${err instanceof Error ? err.message : String(err)}\n`) | ||
| process.exit(1) | ||
| } | ||
| const { url, username, token } = args | ||
| if (!url || !username || !token) { | ||
| process.stderr.write('setup-confluence: --url, --username and --token are all required\n') | ||
| process.exit(1) | ||
| } | ||
| const { path } = writeConfluenceCreds(url, username, token) | ||
| process.stdout.write(`Written: ${path}\n`) | ||
| } | ||
|
|
||
| if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) { | ||
| main().catch((err) => { | ||
| process.stderr.write(`setup-confluence: unexpected error: ${err?.stack ?? err?.message ?? String(err)}\n`) | ||
| process.exit(1) | ||
| }) | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.