@blackbelt-technology/pi-dashboard-extension 0.5.4 → 0.6.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.
- package/.pi/skills/browser/LICENSE +201 -0
- package/.pi/skills/browser/SKILL.md +105 -0
- package/.pi/skills/browser/UPSTREAM.md +46 -0
- package/.pi/skills/browser/references/electron.md +351 -0
- package/.pi/skills/browser/references/web.md +2789 -0
- package/.pi/skills/browser/scripts/detect-dashboard.sh +55 -0
- package/.pi/skills/doctor/AGENTS.md +27 -0
- package/.pi/skills/doctor/SKILL.md +89 -0
- package/.pi/skills/doctor/_lib/checks.ts +177 -0
- package/.pi/skills/doctor/_lib/derive-tokens.ts +43 -0
- package/.pi/skills/doctor/_lib/front-matter.ts +122 -0
- package/.pi/skills/doctor/_lib/index.ts +14 -0
- package/.pi/skills/doctor/_lib/knowledge-hash.ts +74 -0
- package/.pi/skills/doctor/_lib/provenance.ts +50 -0
- package/.pi/skills/doctor/_lib/regenerate.ts +100 -0
- package/.pi/skills/doctor/_lib/router.ts +155 -0
- package/.pi/skills/doctor/_lib/server-tier.ts +62 -0
- package/.pi/skills/doctor/modules/build-reload.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/build-reload.md +51 -0
- package/.pi/skills/doctor/modules/env-node.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/env-node.md +49 -0
- package/.pi/skills/doctor/modules/install-topology.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/install-topology.md +53 -0
- package/.pi/skills/doctor/modules/model-resolution.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/model-resolution.md +53 -0
- package/.pi/skills/doctor/modules/peers.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/peers.md +57 -0
- package/.pi/skills/doctor/modules/pi-resolution.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/pi-resolution.md +60 -0
- package/.pi/skills/doctor/modules/plugins-bridges.knowledge.hash +1 -0
- package/.pi/skills/doctor/modules/plugins-bridges.md +56 -0
- package/.pi/skills/pi-dashboard/SKILL.md +68 -0
- package/.pi/skills/pi-dashboard/commands/README.md +45 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-flow-abort.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-flow-auto.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-git-branches.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-git-init.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-git-stash-pop.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-list-models.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-peer-list.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-peer-scan.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-pin-list.md +5 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-proposal-archive.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-proposal-attach.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-proposal-detach.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-config.md +5 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-health.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-off.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-on.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-server-tunnel-status.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-abort-all.md +14 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-abort.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-diff.md +11 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-fork.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-hide.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-info.md +11 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-kill.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-list-active.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-list-here.md +8 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-list.md +6 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-model.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-rename.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-resume.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-spawn.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-tell.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-thinking.md +10 -0
- package/.pi/skills/pi-dashboard/commands/dashboard-session-unhide.md +10 -0
- package/.pi/skills/pi-dashboard/references/api-reference.md +30 -0
- package/.pi/skills/pi-dashboard/references/recipes.md +38 -0
- package/.pi/skills/pi-dashboard/references/slash-commands.md +71 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-api.sh +6 -0
- package/.pi/skills/pi-dashboard/scripts/dashboard-bus.ts +217 -0
- package/.pi/skills/project-init/SKILL.md +279 -0
- package/.pi/skills/project-init/dox-doctrine.md +104 -0
- package/.pi/skills/project-init/profiles/coding/AGENTS.md.tmpl +111 -0
- package/.pi/skills/project-init/profiles/coding/profile.json +5 -0
- package/.pi/skills/project-init/profiles/coding/prompts/plan-change.md +5 -0
- package/.pi/skills/project-init/profiles/coding/prompts/tdd-loop.md +6 -0
- package/.pi/skills/project-init/profiles/coding/settings.json.tmpl +9 -0
- package/.pi/skills/project-init/profiles/docs/AGENTS.md.tmpl +37 -0
- package/.pi/skills/project-init/profiles/docs/profile.json +4 -0
- package/.pi/skills/project-init/profiles/docs/prompts/draft-page.md +5 -0
- package/.pi/skills/project-init/profiles/docs/settings.json.tmpl +9 -0
- package/package.json +12 -4
- package/src/AGENTS.md +56 -0
- package/src/__tests__/abort-latch.test.ts +97 -0
- package/src/__tests__/agent-settled.test.ts +82 -0
- package/src/__tests__/artifact-roots.test.ts +83 -0
- package/src/__tests__/ask-user-attachments.test.ts +106 -0
- package/src/__tests__/ask-user-tool.test.ts +90 -27
- package/src/__tests__/auto-session-namer.test.ts +339 -0
- package/src/__tests__/bridge-default-model-apply.test.ts +242 -0
- package/src/__tests__/bridge-default-model-gate.test.ts +6 -3
- package/src/__tests__/bridge-followup-mutation.test.ts +217 -0
- package/src/__tests__/bridge-followup-queue-drain.test.ts +266 -0
- package/src/__tests__/bridge-hasui-flip.test.ts +109 -0
- package/src/__tests__/bridge-no-queue-mutation.test.ts +112 -0
- package/src/__tests__/bridge-plugin-emit-event.test.ts +44 -0
- package/src/__tests__/bridge-shutdown-reset.test.ts +57 -136
- package/src/__tests__/bridge-slash-command-routing.test.ts +7 -7
- package/src/__tests__/bridge-stop-after-turn.test.ts +72 -0
- package/src/__tests__/bridge-system-followup.test.ts +163 -0
- package/src/__tests__/bridge-thinking-level-select.test.ts +68 -0
- package/src/__tests__/browser-skill-registered.test.ts +84 -0
- package/src/__tests__/build-provider-catalogue.test.ts +35 -1
- package/src/__tests__/command-handler.test.ts +331 -35
- package/src/__tests__/commit-draft.test.ts +100 -0
- package/src/__tests__/connection-dropped-frames.test.ts +78 -0
- package/src/__tests__/custom-provider-apikey-roundtrip.test.ts +128 -0
- package/src/__tests__/cwd-missing-probe.test.ts +82 -0
- package/src/__tests__/dashboard-commands-shipped.test.ts +53 -0
- package/src/__tests__/dashboard-context-injector.test.ts +190 -0
- package/src/__tests__/doctor/checks.test.ts +121 -0
- package/src/__tests__/doctor/modules.test.ts +64 -0
- package/src/__tests__/doctor/provenance-hash.test.ts +94 -0
- package/src/__tests__/doctor/router.test.ts +143 -0
- package/src/__tests__/empty-actionable-guard-config.test.ts +32 -0
- package/src/__tests__/empty-actionable-guard.test.ts +73 -0
- package/src/__tests__/enrich-model-metadata.test.ts +21 -0
- package/src/__tests__/extension-slash-command-detection.test.ts +37 -1
- package/src/__tests__/filter-enabled-models.test.ts +151 -0
- package/src/__tests__/fixtures/turn-actionability-fixtures.ts +69 -0
- package/src/__tests__/git-info-status.test.ts +73 -0
- package/src/__tests__/git-poll.test.ts +69 -0
- package/src/__tests__/markdown-image-inliner.test.ts +37 -0
- package/src/__tests__/model-resolve.test.ts +379 -0
- package/src/__tests__/pi-version-tracker.test.ts +109 -0
- package/src/__tests__/process-scanner.test.ts +112 -22
- package/src/__tests__/project-init-detect-stack.test.ts +61 -0
- package/src/__tests__/project-init-dox-kb-config.test.ts +53 -0
- package/src/__tests__/project-init-profiles.test.ts +84 -0
- package/src/__tests__/project-init-scaffold.test.ts +139 -0
- package/src/__tests__/project-init-seed-doctrine.test.ts +100 -0
- package/src/__tests__/project-trust.test.ts +92 -0
- package/src/__tests__/prompt-expander.test.ts +191 -1
- package/src/__tests__/provider-register-reload.test.ts +36 -6
- package/src/__tests__/provider-register-thinking-levels.test.ts +51 -0
- package/src/__tests__/retry-tracker.test.ts +75 -70
- package/src/__tests__/role-manager.test.ts +585 -0
- package/src/__tests__/role-model-tools-registry-readiness.test.ts +114 -0
- package/src/__tests__/role-model-tools.test.ts +229 -0
- package/src/__tests__/search-files-completeness.test.ts +111 -0
- package/src/__tests__/search-files-ranking.test.ts +168 -0
- package/src/__tests__/server-auto-start.test.ts +121 -4
- package/src/__tests__/server-launcher-launch.test.ts +24 -6
- package/src/__tests__/server-launcher.test.ts +19 -2
- package/src/__tests__/session-sync.test.ts +36 -0
- package/src/__tests__/subagent-frame-buffer.test.ts +239 -0
- package/src/__tests__/tool-result-image-inliner.test.ts +206 -0
- package/src/__tests__/tui-prompt-adapter.test.ts +70 -64
- package/src/__tests__/turn-actionability.test.ts +86 -0
- package/src/__tests__/vcs-info.test.ts +145 -4
- package/src/__tests__/visibility-intent.test.ts +43 -0
- package/src/abort-latch.ts +55 -0
- package/src/abort-latch.ts.AGENTS.md +3 -0
- package/src/agent-settled.ts +72 -0
- package/src/agent-settled.ts.AGENTS.md +3 -0
- package/src/artifact-roots.ts +73 -0
- package/src/artifact-roots.ts.AGENTS.md +3 -0
- package/src/ask-user-attachments.ts +121 -0
- package/src/ask-user-attachments.ts.AGENTS.md +3 -0
- package/src/ask-user-tool.ts +56 -58
- package/src/ask-user-tool.ts.AGENTS.md +3 -0
- package/src/auto-session-namer.ts +334 -0
- package/src/auto-session-namer.ts.AGENTS.md +3 -0
- package/src/bridge-context.ts +86 -8
- package/src/bridge-context.ts.AGENTS.md +3 -0
- package/src/bridge-default-model-gate.ts +22 -6
- package/src/bridge-default-model-gate.ts.AGENTS.md +3 -0
- package/src/bridge.ts +1241 -360
- package/src/bridge.ts.AGENTS.md +3 -0
- package/src/canvas-tool.ts +107 -0
- package/src/command-handler.ts +490 -51
- package/src/command-handler.ts.AGENTS.md +3 -0
- package/src/commit-draft-agent.ts +114 -0
- package/src/commit-draft-agent.ts.AGENTS.md +3 -0
- package/src/commit-draft.ts +136 -0
- package/src/commit-draft.ts.AGENTS.md +3 -0
- package/src/connection.ts +32 -1
- package/src/connection.ts.AGENTS.md +3 -0
- package/src/dashboard-context-injector.ts +124 -0
- package/src/dashboard-context-injector.ts.AGENTS.md +3 -0
- package/src/dashboard-default-adapter.ts.AGENTS.md +3 -0
- package/src/dev-build.ts.AGENTS.md +3 -0
- package/src/empty-actionable-guard-config.ts +32 -0
- package/src/empty-actionable-guard-config.ts.AGENTS.md +3 -0
- package/src/empty-actionable-guard.ts +90 -0
- package/src/empty-actionable-guard.ts.AGENTS.md +3 -0
- package/src/event-forwarder.ts.AGENTS.md +3 -0
- package/src/flow-event-wiring.ts +4 -14
- package/src/flow-event-wiring.ts.AGENTS.md +3 -0
- package/src/git-link-builder.ts.AGENTS.md +3 -0
- package/src/git-poll.ts +38 -0
- package/src/git-poll.ts.AGENTS.md +3 -0
- package/src/hasui-flip.ts +56 -0
- package/src/hasui-flip.ts.AGENTS.md +3 -0
- package/src/markdown-image-inliner.ts +45 -2
- package/src/markdown-image-inliner.ts.AGENTS.md +3 -0
- package/src/model-tracker.ts +145 -19
- package/src/model-tracker.ts.AGENTS.md +3 -0
- package/src/multiselect-decode.ts.AGENTS.md +3 -0
- package/src/multiselect-list.ts.AGENTS.md +3 -0
- package/src/multiselect-polyfill.ts.AGENTS.md +3 -0
- package/src/process-metrics.ts.AGENTS.md +3 -0
- package/src/process-scanner.ts +114 -103
- package/src/process-scanner.ts.AGENTS.md +3 -0
- package/src/project-init/AGENTS.md +12 -0
- package/src/project-init/detect-stack.ts +146 -0
- package/src/project-init/dox-kb-config.ts +47 -0
- package/src/project-init/profiles.ts +135 -0
- package/src/project-init/scaffold.ts +192 -0
- package/src/project-init/seed-doctrine.ts +95 -0
- package/src/project-trust.ts +63 -0
- package/src/project-trust.ts.AGENTS.md +3 -0
- package/src/prompt-bus.ts +10 -1
- package/src/prompt-bus.ts.AGENTS.md +3 -0
- package/src/prompt-expander.ts +238 -37
- package/src/prompt-expander.ts.AGENTS.md +3 -0
- package/src/provider-register.ts +323 -54
- package/src/provider-register.ts.AGENTS.md +3 -0
- package/src/retry-tracker.ts +64 -39
- package/src/retry-tracker.ts.AGENTS.md +3 -0
- package/src/role-manager.ts +436 -0
- package/src/role-manager.ts.AGENTS.md +3 -0
- package/src/role-model-tools.ts +301 -0
- package/src/role-model-tools.ts.AGENTS.md +3 -0
- package/src/server-auto-start.ts +59 -23
- package/src/server-auto-start.ts.AGENTS.md +3 -0
- package/src/server-launcher.ts +56 -16
- package/src/server-launcher.ts.AGENTS.md +3 -0
- package/src/session-sync.ts +111 -15
- package/src/session-sync.ts.AGENTS.md +3 -0
- package/src/slash-dispatch.ts +13 -11
- package/src/slash-dispatch.ts.AGENTS.md +3 -0
- package/src/source-detector.ts.AGENTS.md +3 -0
- package/src/subagent-frame-buffer.ts +220 -0
- package/src/subagent-frame-buffer.ts.AGENTS.md +3 -0
- package/src/tool-result-image-inliner.ts +204 -0
- package/src/tool-result-image-inliner.ts.AGENTS.md +3 -0
- package/src/tui-prompt-adapter.ts +123 -0
- package/src/tui-prompt-adapter.ts.AGENTS.md +3 -0
- package/src/turn-actionability.ts +117 -0
- package/src/turn-actionability.ts.AGENTS.md +3 -0
- package/src/ui-modules.ts.AGENTS.md +3 -0
- package/src/vcs-info.ts +91 -129
- package/src/vcs-info.ts.AGENTS.md +3 -0
- package/src/visibility-intent.ts +34 -0
- package/src/visibility-intent.ts.AGENTS.md +3 -0
- package/src/__tests__/bridge-retry-ordering.test.ts +0 -148
- package/src/__tests__/bridge-shadow-queue-drain.test.ts +0 -221
- package/src/__tests__/fixtures/usage-limit-error-strings.ts +0 -127
- package/src/__tests__/usage-limit-orderer.test.ts +0 -117
- package/src/__tests__/vcs-info-jj.test.ts +0 -145
- package/src/usage-limit-orderer.ts +0 -93
|
@@ -9,6 +9,44 @@ BASE="http://localhost:$PORT"
|
|
|
9
9
|
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
+
## Typed bus scripting
|
|
13
|
+
|
|
14
|
+
For COMMAND-verb orchestration, prefer the typed WebSocket bus client over curl.
|
|
15
|
+
Write an ordinary type-checked `.ts` script importing `{ connect }` from
|
|
16
|
+
`@blackbelt-technology/pi-dashboard-bus-client` — it discovers the port itself,
|
|
17
|
+
spawn/resume replies are exact-correlated, and other waits are structural
|
|
18
|
+
(session-id + status). Run it with `npx tsx <script>.ts`.
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { connect } from "@blackbelt-technology/pi-dashboard-bus-client";
|
|
22
|
+
|
|
23
|
+
const bus = await connect();
|
|
24
|
+
try {
|
|
25
|
+
// Spawn a session (reply is exact-correlated to this spawn).
|
|
26
|
+
const { sessionId } = await bus.spawn({ cwd: "/path/to/project" });
|
|
27
|
+
|
|
28
|
+
// Drive it: prompt → wait until idle → read result.
|
|
29
|
+
await bus.prompt(sessionId, "Run the test suite and fix any failures");
|
|
30
|
+
await bus.until(sessionId, "idle");
|
|
31
|
+
|
|
32
|
+
const sessions = await bus.read.sessions();
|
|
33
|
+
const me = sessions.find((s) => s.id === sessionId);
|
|
34
|
+
console.log("status:", me?.status);
|
|
35
|
+
|
|
36
|
+
// Follow-up step, then set a goal via the goal plugin.
|
|
37
|
+
await bus.prompt(sessionId, "Now commit the fix");
|
|
38
|
+
await bus.until(sessionId, "idle");
|
|
39
|
+
await bus.plugin("goal", { action: "set", sessionId, text: "green tests" });
|
|
40
|
+
} finally {
|
|
41
|
+
await bus.close();
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For one-shot verbs the [`scripts/dashboard-bus.ts`](../scripts/dashboard-bus.ts)
|
|
46
|
+
CLI covers the same bus without writing a script (see SKILL.md).
|
|
47
|
+
|
|
48
|
+
---
|
|
49
|
+
|
|
12
50
|
## Recipe 1: Spawn a Session, Send a Prompt, Monitor Completion
|
|
13
51
|
|
|
14
52
|
Spawn a new pi session, wait for it to register, send a task, and poll until it finishes.
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
# Pi Dashboard Slash Commands
|
|
2
|
+
|
|
3
|
+
Every `/dashboard:*` command, its arguments, what it does, and whether it runs
|
|
4
|
+
without the LLM. Templates live in [`../commands/`](../commands/).
|
|
5
|
+
|
|
6
|
+
- **LLM-free** = `executable: bash` frontmatter. Body runs as bash; output
|
|
7
|
+
renders in chat; the LLM is never invoked. A footer "ℹ ran locally — LLM not
|
|
8
|
+
invoked" appears beneath the output. These get `PI_DASHBOARD_PORT` /
|
|
9
|
+
`PI_DASHBOARD_BASE` env injected.
|
|
10
|
+
- **LLM-bound** = no `executable` frontmatter. The body expands into a user
|
|
11
|
+
message the LLM interprets (mutations needing judgment or free-form text).
|
|
12
|
+
|
|
13
|
+
Naming grammar: `/dashboard:<resource>-<verb>[-<modifier>]`. Resource is
|
|
14
|
+
singular. Files are `dashboard-<resource>-<verb>[-<modifier>].md`.
|
|
15
|
+
|
|
16
|
+
> The `/dashboard:session-*` and `/dashboard:flow-*` MUTATION commands are now
|
|
17
|
+
> bus-backed: their bodies invoke the typed WebSocket bus CLI
|
|
18
|
+
> (`scripts/dashboard-bus.ts`) instead of curling REST. See SKILL.md.
|
|
19
|
+
|
|
20
|
+
## LLM-free (read-only, no token cost)
|
|
21
|
+
|
|
22
|
+
| Command | Args | Does |
|
|
23
|
+
|---|---|---|
|
|
24
|
+
| `/dashboard:server-health` | — | Server pid + uptime. |
|
|
25
|
+
| `/dashboard:server-config` | — | Server config (secrets redacted). |
|
|
26
|
+
| `/dashboard:server-tunnel-status` | — | Tunnel status + public URL. |
|
|
27
|
+
| `/dashboard:session-list` | — | All sessions: id, status, name, cwd. |
|
|
28
|
+
| `/dashboard:session-list-active` | — | Streaming/active sessions only. |
|
|
29
|
+
| `/dashboard:session-list-here` | — | Sessions whose cwd == current dir. |
|
|
30
|
+
| `/dashboard:session-info` | `<id-prefix>` | Every field of the matched session. |
|
|
31
|
+
| `/dashboard:session-diff` | `<id-prefix>` | File changes (git diff) for the session. |
|
|
32
|
+
| `/dashboard:proposal-archive` | — | Archived OpenSpec changes for cwd (newest first). |
|
|
33
|
+
| `/dashboard:git-branches` | — | Git branches for cwd (current marked `*`). |
|
|
34
|
+
| `/dashboard:peer-list` | — | Known remote dashboard servers. |
|
|
35
|
+
| `/dashboard:peer-scan` | — | mDNS scan for peer servers on the network. |
|
|
36
|
+
| `/dashboard:pin-list` | — | Pinned directories. |
|
|
37
|
+
|
|
38
|
+
## LLM-bound (mutations / judgment)
|
|
39
|
+
|
|
40
|
+
| Command | Args | Does |
|
|
41
|
+
|---|---|---|
|
|
42
|
+
| `/dashboard:session-tell` | `<id-prefix> <text>` | Send a prompt to another session. |
|
|
43
|
+
| `/dashboard:session-abort` | `<id-prefix>` | Abort the session's current run. |
|
|
44
|
+
| `/dashboard:session-abort-all` | `[filter]` | Abort multiple running sessions (asks scope first). |
|
|
45
|
+
| `/dashboard:session-kill` | `<id-prefix>` | Shut down a session (DESTRUCTIVE; confirms). |
|
|
46
|
+
| `/dashboard:session-rename` | `<id-prefix> <name>` | Rename a session. |
|
|
47
|
+
| `/dashboard:session-hide` | `<id-prefix>` | Hide a session from the list. |
|
|
48
|
+
| `/dashboard:session-unhide` | `<id-prefix>` | Unhide a hidden session. |
|
|
49
|
+
| `/dashboard:session-spawn` | `[cwd]` | Spawn a new session (default cwd = current dir). |
|
|
50
|
+
| `/dashboard:session-resume` | `<id-prefix>` | Resume a session (continue mode). |
|
|
51
|
+
| `/dashboard:session-fork` | `<id-prefix>` | Fork a session into a new one. |
|
|
52
|
+
| `/dashboard:list-models` | `[annotated]` | List reachable models via `GET /api/models`; `annotated` adds `excludedReason`. Never file-parse. |
|
|
53
|
+
| `/dashboard:session-model` | `<id-prefix> <provider/modelId>` | Switch a session's model. |
|
|
54
|
+
| `/dashboard:session-thinking` | `<id-prefix> <level>` | Set a session's thinking level. |
|
|
55
|
+
| `/dashboard:proposal-attach` | `<id-prefix> <change-name>` | Attach an OpenSpec change to a session. |
|
|
56
|
+
| `/dashboard:proposal-detach` | `<id-prefix>` | Detach the OpenSpec change. |
|
|
57
|
+
| `/dashboard:flow-abort` | `<id-prefix>` | Abort the running flow. |
|
|
58
|
+
| `/dashboard:flow-auto` | `<id-prefix>` | Toggle autonomous mode for the flow. |
|
|
59
|
+
| `/dashboard:git-init` | `[cwd]` | git init in a directory (default current dir). |
|
|
60
|
+
| `/dashboard:git-stash-pop` | `[cwd]` | git stash pop in a directory (default current dir). |
|
|
61
|
+
| `/dashboard:server-tunnel-on` | — | Connect the public tunnel. |
|
|
62
|
+
| `/dashboard:server-tunnel-off` | — | Disconnect the public tunnel. |
|
|
63
|
+
|
|
64
|
+
## Notes
|
|
65
|
+
|
|
66
|
+
- **Quoting**: positional args for LLM-free commands are whitespace-split; v1
|
|
67
|
+
does not honour quotes. Every LLM-free command takes simple identifiers, so
|
|
68
|
+
this never bites. Free-form text (`session-tell`) is LLM-bound by design.
|
|
69
|
+
- **id-prefix**: any leading substring of a session id; the first match wins.
|
|
70
|
+
- **Disjoint from extension commands**: a `pi.registerCommand` extension
|
|
71
|
+
command of the same name takes precedence (extension dispatch runs first).
|
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Pi Dashboard API helper — wraps curl with port auto-detection and JSON formatting.
|
|
3
3
|
#
|
|
4
|
+
# This is the REST layer for READ-ONLY + no-WS-twin operations (session/health/
|
|
5
|
+
# config reads, git ops, grep/browse, plugin_config_write, tunnel, peer scan,
|
|
6
|
+
# openspec archive/toggle). Session/flow COMMAND verbs (abort, send_prompt,
|
|
7
|
+
# spawn, resume, flow_control, set_model/thinking, rename, hide/unhide,
|
|
8
|
+
# attach/detach_proposal) should use scripts/dashboard-bus.ts — the typed WS bus.
|
|
9
|
+
#
|
|
4
10
|
# Usage:
|
|
5
11
|
# ./dashboard-api.sh METHOD PATH [JSON_BODY]
|
|
6
12
|
#
|
|
@@ -0,0 +1,217 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pi Dashboard bus CLI — the typed WebSocket command layer for the
|
|
3
|
+
* `pi-dashboard` skill. Wraps `@blackbelt-technology/pi-dashboard-bus-client`
|
|
4
|
+
* so slash commands and LLM-authored `.ts` scripts drive the dashboard over the
|
|
5
|
+
* SAME bus the web client uses, instead of curling the REST facade.
|
|
6
|
+
*
|
|
7
|
+
* Tier 2 (this file): the session/flow COMMAND verbs that have a real
|
|
8
|
+
* `BrowserToServerMessage` twin ride the WS. Read-only + no-WS-twin operations
|
|
9
|
+
* stay on `dashboard-api.sh` (REST) — see SKILL.md.
|
|
10
|
+
*
|
|
11
|
+
* Invoke (Node everywhere via npx tsx):
|
|
12
|
+
* npx tsx ./scripts/dashboard-bus.ts sessions [--all] [--json]
|
|
13
|
+
* npx tsx ./scripts/dashboard-bus.ts spawn <cwd> [--prompt <text>] [--attach <change>]
|
|
14
|
+
* npx tsx ./scripts/dashboard-bus.ts prompt <id-prefix> <text...>
|
|
15
|
+
* npx tsx ./scripts/dashboard-bus.ts until <id-prefix> <status> [--timeout <ms>]
|
|
16
|
+
* npx tsx ./scripts/dashboard-bus.ts abort <id-prefix>
|
|
17
|
+
* npx tsx ./scripts/dashboard-bus.ts kill <id-prefix>
|
|
18
|
+
* npx tsx ./scripts/dashboard-bus.ts model <id-prefix> <provider> <modelId>
|
|
19
|
+
* npx tsx ./scripts/dashboard-bus.ts thinking <id-prefix> <level>
|
|
20
|
+
* npx tsx ./scripts/dashboard-bus.ts rename <id-prefix> <name...>
|
|
21
|
+
* npx tsx ./scripts/dashboard-bus.ts hide|unhide <id-prefix>
|
|
22
|
+
* npx tsx ./scripts/dashboard-bus.ts resume <id-prefix> [--fork]
|
|
23
|
+
* npx tsx ./scripts/dashboard-bus.ts flow <id-prefix> <abort|toggle_autonomous|dismiss_summary>
|
|
24
|
+
* npx tsx ./scripts/dashboard-bus.ts proposal-attach <id-prefix> <change>
|
|
25
|
+
* npx tsx ./scripts/dashboard-bus.ts proposal-detach <id-prefix>
|
|
26
|
+
* npx tsx ./scripts/dashboard-bus.ts plugin <pluginId> <action> [payloadJson] [--session <id-prefix>]
|
|
27
|
+
* npx tsx ./scripts/dashboard-bus.ts send '<BrowserToServerMessage json>'
|
|
28
|
+
*
|
|
29
|
+
* See OpenSpec change: add-dashboard-bus-client-scripting.
|
|
30
|
+
*/
|
|
31
|
+
import { BusClient } from "@blackbelt-technology/pi-dashboard-bus-client";
|
|
32
|
+
import type { SessionStatus } from "@blackbelt-technology/pi-dashboard-shared/types.js";
|
|
33
|
+
|
|
34
|
+
function flag(args: string[], name: string): string | undefined {
|
|
35
|
+
const i = args.indexOf(`--${name}`);
|
|
36
|
+
return i >= 0 ? args[i + 1] : undefined;
|
|
37
|
+
}
|
|
38
|
+
function has(args: string[], name: string): boolean {
|
|
39
|
+
return args.includes(`--${name}`);
|
|
40
|
+
}
|
|
41
|
+
function positionals(args: string[]): string[] {
|
|
42
|
+
const out: string[] = [];
|
|
43
|
+
for (let i = 0; i < args.length; i++) {
|
|
44
|
+
const a = args[i];
|
|
45
|
+
if (a.startsWith("--")) {
|
|
46
|
+
// Skip the flag and its value (except boolean flags).
|
|
47
|
+
if (["all", "json", "fork"].includes(a.slice(2))) continue;
|
|
48
|
+
i++;
|
|
49
|
+
continue;
|
|
50
|
+
}
|
|
51
|
+
out.push(a);
|
|
52
|
+
}
|
|
53
|
+
return out;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function die(msg: string): never {
|
|
57
|
+
console.error(`ERROR: ${msg}`);
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
async function main(): Promise<void> {
|
|
62
|
+
const [cmd, ...rest] = process.argv.slice(2);
|
|
63
|
+
if (!cmd) die("usage: dashboard-bus.ts <command> … (see file header)");
|
|
64
|
+
|
|
65
|
+
const client = new BusClient();
|
|
66
|
+
await client.connect();
|
|
67
|
+
|
|
68
|
+
const resolveId = (prefix: string): string => {
|
|
69
|
+
const match = client.read.sessions().find((s) => s.id.startsWith(prefix));
|
|
70
|
+
if (!match) die(`no session id starts with "${prefix}"`);
|
|
71
|
+
return match.id;
|
|
72
|
+
};
|
|
73
|
+
const pos = positionals(rest);
|
|
74
|
+
|
|
75
|
+
try {
|
|
76
|
+
switch (cmd) {
|
|
77
|
+
case "sessions": {
|
|
78
|
+
const all = has(rest, "all");
|
|
79
|
+
const rows = client.read.sessions().filter((s) => all || s.status !== "ended");
|
|
80
|
+
if (has(rest, "json")) {
|
|
81
|
+
console.log(JSON.stringify(rows, null, 2));
|
|
82
|
+
} else {
|
|
83
|
+
for (const s of rows) {
|
|
84
|
+
console.log(
|
|
85
|
+
`${s.id.slice(0, 8)} ${s.status.padEnd(9)} ${s.model ?? "-"} ${s.cwd}`,
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
console.log(`(${rows.length} session${rows.length === 1 ? "" : "s"})`);
|
|
89
|
+
}
|
|
90
|
+
break;
|
|
91
|
+
}
|
|
92
|
+
case "spawn": {
|
|
93
|
+
const cwd = pos[0] ?? die("spawn needs <cwd>");
|
|
94
|
+
const id = await client.spawn({
|
|
95
|
+
cwd,
|
|
96
|
+
initialPrompt: flag(rest, "prompt"),
|
|
97
|
+
attachProposal: flag(rest, "attach"),
|
|
98
|
+
});
|
|
99
|
+
console.log(`spawned ${id}`);
|
|
100
|
+
break;
|
|
101
|
+
}
|
|
102
|
+
case "prompt": {
|
|
103
|
+
const id = resolveId(pos[0] ?? die("prompt needs <id-prefix> <text>"));
|
|
104
|
+
const text = pos.slice(1).join(" ");
|
|
105
|
+
if (!text) die("prompt needs text");
|
|
106
|
+
client.prompt(id, text);
|
|
107
|
+
console.log(`prompted ${id.slice(0, 8)}`);
|
|
108
|
+
break;
|
|
109
|
+
}
|
|
110
|
+
case "until": {
|
|
111
|
+
const id = resolveId(pos[0] ?? die("until needs <id-prefix> <status>"));
|
|
112
|
+
const status = (pos[1] ?? die("until needs a status")) as SessionStatus;
|
|
113
|
+
const timeout = Number(flag(rest, "timeout") ?? 300_000);
|
|
114
|
+
await client.until(id, status, { timeout });
|
|
115
|
+
console.log(`${id.slice(0, 8)} reached ${status}`);
|
|
116
|
+
break;
|
|
117
|
+
}
|
|
118
|
+
case "abort": {
|
|
119
|
+
const id = resolveId(pos[0] ?? die("abort needs <id-prefix>"));
|
|
120
|
+
client.send({ type: "abort", sessionId: id });
|
|
121
|
+
console.log(`aborted ${id.slice(0, 8)}`);
|
|
122
|
+
break;
|
|
123
|
+
}
|
|
124
|
+
case "kill": {
|
|
125
|
+
const id = resolveId(pos[0] ?? die("kill needs <id-prefix>"));
|
|
126
|
+
client.send({ type: "force_kill", sessionId: id });
|
|
127
|
+
console.log(`force-killed ${id.slice(0, 8)}`);
|
|
128
|
+
break;
|
|
129
|
+
}
|
|
130
|
+
case "model": {
|
|
131
|
+
const id = resolveId(pos[0] ?? die("model needs <id-prefix> <provider> <modelId>"));
|
|
132
|
+
const provider = pos[1] ?? die("model needs <provider>");
|
|
133
|
+
const modelId = pos[2] ?? die("model needs <modelId>");
|
|
134
|
+
client.send({ type: "set_model", sessionId: id, provider, modelId });
|
|
135
|
+
console.log(`set model ${provider}/${modelId} on ${id.slice(0, 8)}`);
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
case "thinking": {
|
|
139
|
+
const id = resolveId(pos[0] ?? die("thinking needs <id-prefix> <level>"));
|
|
140
|
+
const level = pos[1] ?? die("thinking needs <level>");
|
|
141
|
+
client.send({ type: "set_thinking_level", sessionId: id, level });
|
|
142
|
+
console.log(`set thinking ${level} on ${id.slice(0, 8)}`);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
case "rename": {
|
|
146
|
+
const id = resolveId(pos[0] ?? die("rename needs <id-prefix> <name>"));
|
|
147
|
+
const name = pos.slice(1).join(" ") || die("rename needs a name");
|
|
148
|
+
client.send({ type: "rename_session", sessionId: id, name });
|
|
149
|
+
console.log(`renamed ${id.slice(0, 8)} → ${name}`);
|
|
150
|
+
break;
|
|
151
|
+
}
|
|
152
|
+
case "hide":
|
|
153
|
+
case "unhide": {
|
|
154
|
+
const id = resolveId(pos[0] ?? die(`${cmd} needs <id-prefix>`));
|
|
155
|
+
client.send({ type: cmd === "hide" ? "hide_session" : "unhide_session", sessionId: id });
|
|
156
|
+
console.log(`${cmd} ${id.slice(0, 8)}`);
|
|
157
|
+
break;
|
|
158
|
+
}
|
|
159
|
+
case "resume": {
|
|
160
|
+
const id = resolveId(pos[0] ?? die("resume needs <id-prefix>"));
|
|
161
|
+
const newId = await client.resume({ sessionId: id, mode: has(rest, "fork") ? "fork" : "continue" });
|
|
162
|
+
console.log(`resumed ${id.slice(0, 8)} → ${newId}`);
|
|
163
|
+
break;
|
|
164
|
+
}
|
|
165
|
+
case "flow": {
|
|
166
|
+
const id = resolveId(pos[0] ?? die("flow needs <id-prefix> <action>"));
|
|
167
|
+
const action = pos[1] as "abort" | "toggle_autonomous" | "dismiss_summary";
|
|
168
|
+
if (!["abort", "toggle_autonomous", "dismiss_summary"].includes(action)) {
|
|
169
|
+
die("flow action must be abort|toggle_autonomous|dismiss_summary");
|
|
170
|
+
}
|
|
171
|
+
client.send({ type: "flow_control", sessionId: id, action });
|
|
172
|
+
console.log(`flow ${action} on ${id.slice(0, 8)}`);
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
case "proposal-attach": {
|
|
176
|
+
const id = resolveId(pos[0] ?? die("proposal-attach needs <id-prefix> <change>"));
|
|
177
|
+
const changeName = pos[1] ?? die("proposal-attach needs <change>");
|
|
178
|
+
client.send({ type: "attach_proposal", sessionId: id, changeName });
|
|
179
|
+
console.log(`attached ${changeName} to ${id.slice(0, 8)}`);
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
case "proposal-detach": {
|
|
183
|
+
const id = resolveId(pos[0] ?? die("proposal-detach needs <id-prefix>"));
|
|
184
|
+
client.send({ type: "detach_proposal", sessionId: id });
|
|
185
|
+
console.log(`detached proposal from ${id.slice(0, 8)}`);
|
|
186
|
+
break;
|
|
187
|
+
}
|
|
188
|
+
case "plugin": {
|
|
189
|
+
const pluginId = pos[0] ?? die("plugin needs <pluginId> <action>");
|
|
190
|
+
const action = pos[1] ?? die("plugin needs <action>");
|
|
191
|
+
const payload = pos[2] ? (JSON.parse(pos[2]) as Record<string, unknown>) : undefined;
|
|
192
|
+
const sessionPrefix = flag(rest, "session");
|
|
193
|
+
const sessionId = sessionPrefix ? resolveId(sessionPrefix) : null;
|
|
194
|
+
client.plugin(pluginId, action, payload, { sessionId });
|
|
195
|
+
console.log(`plugin ${pluginId}.${action} sent`);
|
|
196
|
+
break;
|
|
197
|
+
}
|
|
198
|
+
case "send": {
|
|
199
|
+
const json = pos[0] ?? die("send needs a JSON message");
|
|
200
|
+
client.send(JSON.parse(json));
|
|
201
|
+
console.log("sent");
|
|
202
|
+
break;
|
|
203
|
+
}
|
|
204
|
+
default:
|
|
205
|
+
die(`unknown command: ${cmd}`);
|
|
206
|
+
}
|
|
207
|
+
} finally {
|
|
208
|
+
// Give a beat for the last frame to flush, then close.
|
|
209
|
+
await new Promise((r) => setTimeout(r, 50));
|
|
210
|
+
client.close();
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
main().catch((err) => {
|
|
215
|
+
console.error(`ERROR: ${(err as Error).message}`);
|
|
216
|
+
process.exit(1);
|
|
217
|
+
});
|
|
@@ -0,0 +1,279 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: project-init
|
|
3
|
+
description: >
|
|
4
|
+
Scaffold an unconfigured directory into a configured pi project. Interactive,
|
|
5
|
+
profile-driven: lists project profiles (coding, docs, plus user profiles),
|
|
6
|
+
asks which to use, previews the planned writes, and on confirmation writes
|
|
7
|
+
AGENTS.md, .pi/settings.json (with a worktreeInit hook + toolset), and prompt
|
|
8
|
+
files. Use when a bare directory needs turning into a working pi project, or
|
|
9
|
+
when the dashboard's "Initialize" button spawns this session.
|
|
10
|
+
license: MIT
|
|
11
|
+
metadata:
|
|
12
|
+
author: pi-dashboard
|
|
13
|
+
version: "1.0"
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# Project Init
|
|
17
|
+
|
|
18
|
+
Turn the current directory into a configured pi project through a guided,
|
|
19
|
+
conversational flow. You are running as a first-class interactive session —
|
|
20
|
+
converse, confirm, and only write files after the user agrees.
|
|
21
|
+
|
|
22
|
+
**Target directory** = your current working directory (`cwd`). All writes land
|
|
23
|
+
there. All profile/doctrine paths below are relative to THIS skill's directory
|
|
24
|
+
(the folder containing this `SKILL.md`); call it `<skill>`.
|
|
25
|
+
|
|
26
|
+
## Step 1 — Resolve the available profiles
|
|
27
|
+
|
|
28
|
+
A profile is a directory bundle: `profile.json` (optional, carries
|
|
29
|
+
`description` + `dox`), `AGENTS.md.tmpl`, `settings.json.tmpl`, and
|
|
30
|
+
`prompts/*.md`.
|
|
31
|
+
|
|
32
|
+
Enumerate profiles from two sources, **user wins by name**:
|
|
33
|
+
|
|
34
|
+
1. Shipped: `<skill>/profiles/*`
|
|
35
|
+
2. User: `~/.pi/project-profiles/*`
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
ls -1 "<skill>/profiles" 2>/dev/null
|
|
39
|
+
ls -1 "$HOME/.pi/project-profiles" 2>/dev/null
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
Merge: a user profile of the same name fully shadows the shipped one. A
|
|
43
|
+
directory is only a usable profile when it contains BOTH `AGENTS.md.tmpl` and
|
|
44
|
+
`settings.json.tmpl`. Read each `profile.json` for its `description` and `dox`
|
|
45
|
+
flag (`dox` defaults to `false` when absent or unreadable).
|
|
46
|
+
|
|
47
|
+
## Step 2 — Ask which profile
|
|
48
|
+
|
|
49
|
+
Use `ask_user` (select) to present the resolved profiles by name +
|
|
50
|
+
description. Shipped defaults are `coding` (TDD/simplicity/surgical, OpenSpec
|
|
51
|
+
on, `npm ci` worktree-init) and `docs` (writing structure, OpenSpec off, no
|
|
52
|
+
build step).
|
|
53
|
+
|
|
54
|
+
## Step 2b — Resolve the technology stack (stack-aware profiles only)
|
|
55
|
+
|
|
56
|
+
When the chosen profile's `profile.json` has `"stackAware": true` (the shipped
|
|
57
|
+
`coding` profile does), its templates carry technology placeholders
|
|
58
|
+
(`{{INSTALL_CMD}}`, `{{TEST_CMD}}`, `{{BUILD_CMD}}`, `{{INIT_GATE}}`,
|
|
59
|
+
`{{INIT_COMMAND}}`) that must be filled from the project's stack — a coding repo
|
|
60
|
+
may be Node, Rust, Go, Python, Java, etc.
|
|
61
|
+
|
|
62
|
+
**Auto-detect + confirm:**
|
|
63
|
+
|
|
64
|
+
1. Detect a best guess from marker files in the target directory:
|
|
65
|
+
|
|
66
|
+
| Marker file(s) | Stack | install / test / build | init gate + run |
|
|
67
|
+
|---|---|---|---|
|
|
68
|
+
| `pnpm-lock.yaml` | pnpm | `pnpm install --frozen-lockfile` / `pnpm test` / `pnpm build` | `test ! -d node_modules` / `pnpm install --frozen-lockfile` |
|
|
69
|
+
| `yarn.lock` | yarn | `yarn install --frozen-lockfile` / `yarn test` / `yarn build` | `test ! -d node_modules` / `yarn install --frozen-lockfile` |
|
|
70
|
+
| `bun.lockb` / `bun.lock` | bun | `bun install` / `bun test` / `bun run build` | `test ! -d node_modules` / `bun install` |
|
|
71
|
+
| `package-lock.json` / `package.json` | npm | `npm ci` / `npm test` / `npm run build` | `test ! -d node_modules` / `npm ci` |
|
|
72
|
+
| `Cargo.toml` | cargo | `cargo fetch` / `cargo test` / `cargo build` | `test ! -d target` / `cargo fetch` |
|
|
73
|
+
| `go.mod` | go | `go mod download` / `go test ./...` / `go build ./...` | `test ! -f go.sum` / `go mod download` |
|
|
74
|
+
| `poetry.lock` or `pyproject.toml`+`[tool.poetry]` | poetry | `poetry install` / `poetry run pytest` / `poetry build` | `test ! -d .venv` / `poetry install` |
|
|
75
|
+
| `requirements.txt` / `pyproject.toml` | pip | venv+pip install / `.venv/bin/pytest` / `python -m build` | `test ! -d .venv` / venv+pip install |
|
|
76
|
+
| `pom.xml` | maven | `mvn -q dependency:go-offline` / `mvn test` / `mvn -q package -DskipTests` | `test ! -d target` / `mvn -q dependency:go-offline` |
|
|
77
|
+
| `build.gradle`(`.kts`) | gradle | `./gradlew dependencies` / `./gradlew test` / `./gradlew build -x test` | `test ! -d .gradle` / `./gradlew dependencies` |
|
|
78
|
+
|
|
79
|
+
Prefer a JS lockfile over a plain `package.json`. A bare directory yields no
|
|
80
|
+
guess.
|
|
81
|
+
|
|
82
|
+
2. **Confirm with the user** (`ask_user`): show the detected stack (or "none
|
|
83
|
+
detected") and let them confirm or pick a different stack from the table.
|
|
84
|
+
Never scaffold a stack-aware profile without a resolved stack.
|
|
85
|
+
|
|
86
|
+
3. Substitute the chosen stack's values for the `{{…}}` placeholders when
|
|
87
|
+
writing the templates in Step 4. After writing, verify NO `{{…}}` placeholder
|
|
88
|
+
remains in `AGENTS.md` or `.pi/settings.json` — an unfilled placeholder means
|
|
89
|
+
the stack was not resolved; go back and ask.
|
|
90
|
+
|
|
91
|
+
## Step 3 — Ask about optional capabilities, preview, then confirm
|
|
92
|
+
|
|
93
|
+
### 3a — Ask about DOX (all profiles)
|
|
94
|
+
|
|
95
|
+
DOX seeds a directory-level documentation doctrine and wires the kb toolset (see
|
|
96
|
+
Step 5). It is now an **interactive choice on every profile**, not a fixed
|
|
97
|
+
per-profile switch. Ask with `ask_user` (confirm), pre-selecting the profile's
|
|
98
|
+
`dox` value as the DEFAULT answer:
|
|
99
|
+
|
|
100
|
+
> Enable DOX documentation doctrine? Seeds a directory-level AGENTS.md discipline
|
|
101
|
+
> into `./AGENTS.md` and enables the kb toolset. (default: `<profile.dox>`)
|
|
102
|
+
|
|
103
|
+
Record the answer as `DOX_ENABLED`. The `dox` flag in `profile.json` only sets
|
|
104
|
+
the default; the user's answer decides. Step 5 gates on `DOX_ENABLED`, not the
|
|
105
|
+
raw flag.
|
|
106
|
+
|
|
107
|
+
### 3b — Ask about OpenSpec init (coding profile only)
|
|
108
|
+
|
|
109
|
+
**Gate: only when the selected profile is `coding`** (skip for `docs` / any
|
|
110
|
+
OpenSpec-off profile), mirroring Steps 4b and 5. Skip the prompt entirely when an
|
|
111
|
+
`openspec/` directory already exists in the target (idempotent — treat as
|
|
112
|
+
already-initialized). Otherwise ask with `ask_user` (confirm):
|
|
113
|
+
|
|
114
|
+
> Initialize OpenSpec for this project? Runs `openspec init --tools pi`, which
|
|
115
|
+
> creates the `openspec/` scaffold and wires the OpenSpec commands into pi.
|
|
116
|
+
|
|
117
|
+
Record the answer as `OPENSPEC_INIT`. The actual run happens in Step 6.
|
|
118
|
+
|
|
119
|
+
### 3c — Preview + confirm
|
|
120
|
+
|
|
121
|
+
List exactly what you will write, then ask the user to confirm (`ask_user`
|
|
122
|
+
confirm). The writes for profile `<p>` are:
|
|
123
|
+
|
|
124
|
+
- `./AGENTS.md` ← `<skill>/profiles/<p>/AGENTS.md.tmpl` (substitute `{{PROJECT_NAME}}` with the directory basename)
|
|
125
|
+
- `./.pi/settings.json` ← `<skill>/profiles/<p>/settings.json.tmpl`
|
|
126
|
+
- `./.pi/prompts/*.md` ← each file in `<skill>/profiles/<p>/prompts/`
|
|
127
|
+
|
|
128
|
+
When `DOX_ENABLED` is true, ALSO name in the preview:
|
|
129
|
+
|
|
130
|
+
- the DOX doctrine seed appended to `./AGENTS.md` (see Step 5)
|
|
131
|
+
- the kb toolset flip written to `./.pi/dashboard/knowledge_base.json`
|
|
132
|
+
|
|
133
|
+
When `OPENSPEC_INIT` is true, ALSO disclose the side effect (see Step 6) — NOT a
|
|
134
|
+
plain file write:
|
|
135
|
+
|
|
136
|
+
- runs `openspec init --tools pi`, scaffolding `./openspec/` and wiring pi
|
|
137
|
+
|
|
138
|
+
When the chosen profile is `coding`, ALSO disclose the possible side effect (see
|
|
139
|
+
Step 4b) — NOT a file write:
|
|
140
|
+
|
|
141
|
+
- may offer to `pi install` the `eng-disciplines` skills **user-globally**
|
|
142
|
+
(writes `~/.pi/agent/settings.json`). This is machine-wide: the skills become
|
|
143
|
+
available in **all** projects on this machine, not just this one. Always
|
|
144
|
+
opt-in via a separate prompt; never forced. Needs Node/npm on the machine
|
|
145
|
+
(the install runs `pi install npm:…`); the scaffolded repo itself gains no
|
|
146
|
+
dependency.
|
|
147
|
+
|
|
148
|
+
**Idempotency:** before writing, check whether `./AGENTS.md` or
|
|
149
|
+
`./.pi/settings.json` already exist. If they do, ask before overwriting — never
|
|
150
|
+
clobber silently.
|
|
151
|
+
|
|
152
|
+
## Step 4 — Write the scaffold
|
|
153
|
+
|
|
154
|
+
On confirmation, write the files listed above. Substitute `{{PROJECT_NAME}}`
|
|
155
|
+
in `AGENTS.md.tmpl` with the target directory's basename, and — for a
|
|
156
|
+
stack-aware profile — the stack placeholders resolved in Step 2b.
|
|
157
|
+
|
|
158
|
+
**Validate the hook.** After writing `./.pi/settings.json`, confirm its
|
|
159
|
+
`worktreeInit` is a valid change-A hook: a non-empty `gate` string plus a `run`
|
|
160
|
+
that is either `{ type: "script", command: "<non-empty>" }` or
|
|
161
|
+
`{ type: "agent", prompt: "<non-empty>" }`. If it is not valid, warn the user —
|
|
162
|
+
an invalid hook fails open (change-A ignores it) and the Initialize button will
|
|
163
|
+
loop back to this skill instead of running the hook.
|
|
164
|
+
|
|
165
|
+
## Step 4b — Ensure discipline skills (only when the profile is `coding`)
|
|
166
|
+
|
|
167
|
+
The `coding` template's `## Discipline Skills` checkpoint table references the
|
|
168
|
+
`eng-disciplines` skills. This step makes those references live. **Gate: run
|
|
169
|
+
only when the selected profile is `coding`** (skip for `docs` / any
|
|
170
|
+
OpenSpec-off profile), mirroring how Step 5 gates on `dox: true`.
|
|
171
|
+
|
|
172
|
+
**Detect** (read-only; both forms tolerate a missing `pi` binary):
|
|
173
|
+
|
|
174
|
+
```bash
|
|
175
|
+
pi list 2>/dev/null | grep -q pi-dashboard-eng-disciplines \
|
|
176
|
+
|| stat ~/.pi/agent/npm/node_modules/@blackbelt-technology/pi-dashboard-eng-disciplines >/dev/null 2>&1
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
If `pi` is not on PATH and the stat misses, treat as ABSENT but do NOT error
|
|
180
|
+
the init — fall through to the footnote. (Known limit: the stat form only sees
|
|
181
|
+
the `npm:` global path; a `git:`/renamed install is invisible and would
|
|
182
|
+
re-prompt.)
|
|
183
|
+
|
|
184
|
+
**PRESENT** → skills already global. Skip the prompt (idempotent re-run) and
|
|
185
|
+
write NO activation footnote into `./AGENTS.md`. If a prior run left the
|
|
186
|
+
"not detected" footnote (e.g. the skills were installed after a decline),
|
|
187
|
+
remove that line before exiting so the file never claims the skills are missing
|
|
188
|
+
when they are present. Done.
|
|
189
|
+
|
|
190
|
+
**ABSENT** → `ask_user` (confirm):
|
|
191
|
+
|
|
192
|
+
> Install the discipline skills globally? They power the checkpoint table this
|
|
193
|
+
> project's AGENTS.md references, and become available in ALL projects on this
|
|
194
|
+
> machine. Writes `~/.pi/agent/settings.json` (user-global, not project-local).
|
|
195
|
+
|
|
196
|
+
- **Yes** → run `pi install npm:@blackbelt-technology/pi-dashboard-eng-disciplines`
|
|
197
|
+
and verify exit 0. On success, write NO footnote. On non-zero exit (or a
|
|
198
|
+
missing `pi`), fall through to the footnote path.
|
|
199
|
+
- **No / install failed** → append ONE line under the `## Discipline Skills`
|
|
200
|
+
table in `./AGENTS.md`:
|
|
201
|
+
|
|
202
|
+
> Discipline skills not detected — run `pi install npm:@blackbelt-technology/pi-dashboard-eng-disciplines` to activate the checkpoints above.
|
|
203
|
+
|
|
204
|
+
The footnote is **detection-conditional**: written only on the absent/declined
|
|
205
|
+
branch, never on the present/installed path (so a successfully-wired project
|
|
206
|
+
never carries a false "not detected" line). The install is always user-global
|
|
207
|
+
and never forced.
|
|
208
|
+
|
|
209
|
+
## Step 5 — DOX doctrine seed (only when `DOX_ENABLED` is true)
|
|
210
|
+
|
|
211
|
+
> Gated on the user's Step 3a answer (`DOX_ENABLED`), NOT the raw `profile.json`
|
|
212
|
+
> `dox` flag — the flag only supplied the default. Skip this step entirely when
|
|
213
|
+
> the user declined DOX.
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
The canonical doctrine ships once at `<skill>/dox-doctrine.md`. Do NOT copy the
|
|
217
|
+
whole file. Seed a single block into `./AGENTS.md` **only when it does not
|
|
218
|
+
already carry the marker** `<!-- dox-doctrine -->` (idempotent — if the marker
|
|
219
|
+
is present, skip this step entirely).
|
|
220
|
+
|
|
221
|
+
Compose the seeded block as:
|
|
222
|
+
|
|
223
|
+
1. The marker line `<!-- dox-doctrine -->`
|
|
224
|
+
2. The WRITE discipline — the text between `<!-- dox:write:start -->` and
|
|
225
|
+
`<!-- dox:write:end -->` in `dox-doctrine.md`.
|
|
226
|
+
3. ONE READ discipline variant — **skip this item entirely when the chosen
|
|
227
|
+
profile's `AGENTS.md.tmpl` already embeds a `## Finding docs (READ
|
|
228
|
+
discipline)` section** (the shipped `coding` profile does; seeding it again
|
|
229
|
+
would duplicate the gate). Seed only the WRITE discipline in that case.
|
|
230
|
+
Otherwise:
|
|
231
|
+
- If the kb toolset is wired (this profile writes
|
|
232
|
+
`knowledge_base.json` with `indexAgentsFiles`/`directoryLevelAgents`),
|
|
233
|
+
use the text between `<!-- dox:read:kb:start -->` and
|
|
234
|
+
`<!-- dox:read:kb:end -->` (references `kb agents` / `kb_search`).
|
|
235
|
+
- Otherwise use the text between `<!-- dox:read:manual:start -->` and
|
|
236
|
+
`<!-- dox:read:manual:end -->` (manual chain-walk; no kb references).
|
|
237
|
+
|
|
238
|
+
Strip the delimiter comments from the seeded text. Append the block to
|
|
239
|
+
`./AGENTS.md`.
|
|
240
|
+
|
|
241
|
+
Then write `./.pi/dashboard/knowledge_base.json` (when absent) enabling the
|
|
242
|
+
directory-level AGENTS.md toolset:
|
|
243
|
+
|
|
244
|
+
```json
|
|
245
|
+
{
|
|
246
|
+
"sources": [{ "kind": "filesystem", "ref": "." }],
|
|
247
|
+
"indexAgentsFiles": true,
|
|
248
|
+
"directoryLevelAgents": { "enabled": true }
|
|
249
|
+
}
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
## Step 6 — Run OpenSpec init (only when `OPENSPEC_INIT` is true)
|
|
253
|
+
|
|
254
|
+
Gated on the user's Step 3b answer (`OPENSPEC_INIT`); this only becomes true for
|
|
255
|
+
the `coding` profile when no `openspec/` dir pre-existed. Mirrors Step 4b's
|
|
256
|
+
side-effect pattern — opt-in, verified, never forced.
|
|
257
|
+
|
|
258
|
+
**Run** (always non-interactive so it never hijacks the conversation):
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
openspec init --tools pi
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
The `--tools pi` flag pins the wiring to pi and skips OpenSpec's interactive tool
|
|
265
|
+
picker. Verify exit 0 and that `./openspec/` now exists. On success, tell the
|
|
266
|
+
user OpenSpec is wired (the `coding` AGENTS.md already documents
|
|
267
|
+
`openspec change new <name>`). On non-zero exit (or a missing `openspec` binary),
|
|
268
|
+
warn the user and point them at `openspec init --tools pi` to run manually — do
|
|
269
|
+
NOT error the init; the scaffold is already written.
|
|
270
|
+
|
|
271
|
+
**Idempotent re-run:** if `./openspec/` already existed, Step 3b never asked, so
|
|
272
|
+
`OPENSPEC_INIT` is false and this step is skipped — no clobber.
|
|
273
|
+
|
|
274
|
+
## Step 7 — Done
|
|
275
|
+
|
|
276
|
+
Confirm what was written. Writing `worktreeInit` flips the directory to
|
|
277
|
+
"configured": the next dashboard **Initialize** click runs the hook (change-A)
|
|
278
|
+
instead of re-launching this skill. Tell the user they can click Initialize
|
|
279
|
+
again to run `npm ci` (or the profile's hook).
|