@webship.co/workspace-tracker 0.0.0-stage → 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2026 Webship.co
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,155 @@
1
- # Temporary Holding Version
1
+ # @webship.co/workspace-tracker
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ The tracker family's shared base for [Webship Workspace](https://github.com/webship/workspace) plugins. A person picks a
4
+ ticket, a task or a work item of a service (GitHub issues, GitLab work items, an open-source tracker). The dashboard reads
5
+ it once, as data, into a spec. The workspace's AI CLI (the core's `author` role, Claude Code by default) works it on a branch
6
+ of the project in a screen session the person watches. The person decides what goes back: a draft pull or merge request and
7
+ a comment, each a click after a preview, only when writes are on. Nothing is merged, closed, deployed or released.
8
+
9
+ The design, with the review folded in: [#1](https://github.com/webship/workspace-tracker/issues/1).
10
+
11
+ ## Use it in a plugin
12
+
13
+ ```ts
14
+ import { registerTracker } from '@webship.co/workspace-tracker';
15
+
16
+ export function register(api: PluginApi) {
17
+ registerTracker(api, myProvider(api)); // a standalone tracker: a menu of its own
18
+ }
19
+
20
+ // A forge (GitHub, GitLab) keeps one button: its own menu shows the tracker's entries.
21
+ const tracker = registerTracker(api, githubTracker(api), { menu: 'none', settingsBlock: 'tracker' });
22
+ registerForge(api, { ...githubForge(api), menuItems: tracker.menuItems });
23
+ ```
24
+
25
+ A provider is a `TrackerProvider` (`src/provider.ts`). It says how to list and read items, which scope a project works against, and
26
+ what it can do (`capabilities`). Each write is an optional method: `comment`, `worklog`, `transitions` and `transition`, `labels`,
27
+ `assign`, `create`, `openRequest` (a forge pushes the branch and opens a draft request) and `linkRequest`. The UI shows a view or an
28
+ action only when the provider declares it and has the method, and a write also needs writes on. The shape is Jira's on purpose
29
+ (projects with an allowlist, "mine", sprints as the iteration, worklog, transitions, assignee), so the Jira plugin can later be a provider.
30
+
31
+ ## What the base draws
32
+
33
+ | Piece | What it is |
34
+ | --- | --- |
35
+ | The menu | A row menu named for the provider, or entries in a forge's menu: "Issues — get, analyze, work…" and the scope the row works against |
36
+ | The list | Open, Mine, Assigned to…, the current iteration (sprint, milestone, version), Board, Search, as the provider declares. A number typed in the filter opens that item. The agents at work, and per item Open and Do the work |
37
+ | One item | Overview (who wrote it and how they stand with the project, hidden text, the runs), Analyze (read-only, kept as `02-analysis.md`), Do the work, Result, Runs; with writes on, Comment, Log work, Move, Labels, Assign |
38
+ | The result | The branch, its commits and diff stat, what is not committed, the author's notes, Ask the reviewer, Preview the draft request, Preview the comment |
39
+ | The badge | The item a live author session works, on the project's card |
40
+ | New folder | "Create a <noun> for it", written by the dashboard from "What is it for?" (writes on, a default scope set) |
41
+
42
+ ## Do the work
43
+
44
+ 1. **A person starts it.** Nothing starts from the service. One run per item, `max_agents` across the provider.
45
+ 2. **The item is read once** into the core's spec layout, `specs/<ws>/<project>/NNN-<provider>-<item>-<slug>/`: `spec.yml` (target, topic,
46
+ issue, the tracker fields, branch, base, the request once opened) and `01-story.md`, the item framed as data.
47
+ 3. **A branch** in the project (refused while it has uncommitted changes; nothing is stashed), or **a worktree** under
48
+ `.tracker/worktrees/`, outside every workspace folder.
49
+ 4. **The author** is the core's `author` role (`core/config/ai.settings.yml`). Claude Code runs interactively in a screen session, from a
50
+ private script: `claude --session-id … --settings <session settings> --add-dir <spec> --append-system-prompt-file <rules> "$(cat <prompt>)"`.
51
+ No permission mode is passed: the project's own applies. Another author CLI runs through the core runner (`ai-items.sh run --role author`).
52
+ 5. **The result** waits for the person: the branch, the commits, `notes.md`. **The reviewer** (the core's `reviewer` role, a different AI
53
+ provider) reads the diff against the item, kept in `collaboration/` with its verdict.
54
+ 6. **With writes on**, the person previews and posts a draft request (`Closes #N`, the notes, `AI-Generated: Yes`, the Checkpoints with the
55
+ two human-review boxes never ticked) and a comment. Each write is a line in `core/workspace-app/actions.log`.
56
+
57
+ ## The ticket text is untrusted
58
+
59
+ Anyone who can file, edit or comment on an item writes text the AI reads. The main defences:
60
+
61
+ 1. **The session holds no token.** Token variables (`GH_TOKEN`, `GITHUB_TOKEN`, `GITLAB_TOKEN`, …, and the provider's own) are unset in the
62
+ session script and denied inside the sandbox. The plugin's settings file is never sent. The provider's token is used only by the
63
+ dashboard's own calls.
64
+ 2. **The dashboard does every write, after a preview.** The AI never pushes, opens a request, comments, logs work or moves the item. A
65
+ person clicks each write after reading a preview they can edit. A token-shaped string (GitHub, GitLab and Slack tokens, AWS keys, JSON
66
+ Web Tokens, PEM blocks, the provider's own token) blocks the post. Before a push, the dashboard checks that the project's git
67
+ config is what it was when the session started, and its own git commands run with hooks off.
68
+
69
+ Around them:
70
+
71
+ - **The person in charge.** A run starts only from the dashboard, and the opening prompt and the rules are shown before Start.
72
+ An item opened by someone outside the project (not a member or collaborator), or whose body was last edited by such a person, is
73
+ analyze only unless the person ticks a confirmation that names them. With `outsider_items: refuse` it is analyze only.
74
+ - **Data, not instructions.** The rules are the session's system prompt. The item is a file, framed and fenced. Its fence is longer than any run
75
+ of backticks in it. HTML comments, `<details>`, zero-width, bidi and tag characters are made visible. Comments from outside the project
76
+ are left out by default. No ticket text is ever in a shell line or a prompt.
77
+ - **The sandbox.** With `sandbox: required` (the default), the author session runs Claude Code's sandboxed Bash: no network domain
78
+ unless the settings list one, credential files and variables denied, no unsandboxed retry. It refuses to start without the sandbox.
79
+ - **Deny rules**, as defence in depth: `git push`, `gh`, `glab`, `curl`, `wget`, `ssh`, `nc`, `twg`, the provider's CLI, WebFetch,
80
+ WebSearch, and reading `core/config`, `~/.config/gh`, `~/.ssh`, `.env`. A command prefix is not a boundary (`python3 -c` gets past
81
+ it); these catch the obvious, not the determined.
82
+ - **Isolation and review.** A new branch or worktree, a draft request, nothing merged; a reviewer from a different AI provider; the
83
+ author lists the instructions in the item that it did not follow.
84
+
85
+ **The residual risk, plainly:** the session runs as your user. Outside the sandbox, or with `sandbox: off`, it can read what your user
86
+ can read and reach what your user can reach. Inside the sandbox, Read and Glob still see every file the permission rules do not deny. A
87
+ ticket can steer the session within the project and its permissions. **Do the work only on items you trust**, and read the diff before
88
+ any write.
89
+
90
+ ### The sandbox on Ubuntu 24.04
91
+
92
+ Claude Code's sandbox on Linux needs `bubblewrap` and `socat`. Ubuntu 24.04 restricts unprivileged user namespaces
93
+ (`kernel.apparmor_restrict_unprivileged_userns=1`). With that restriction, bubblewrap cannot start, and a session with `sandbox: required`
94
+ refuses to run ("sandbox required but unavailable").
95
+
96
+ The narrow fix allows user namespaces for bubblewrap only. Add its AppArmor profile, then load it:
97
+
98
+ ```bash
99
+ sudo tee /etc/apparmor.d/bwrap > /dev/null <<'EOF'
100
+ abi <abi/4.0>,
101
+ include <tunables/global>
102
+
103
+ profile bwrap /usr/bin/bwrap flags=(unconfined) {
104
+ userns,
105
+ include if exists <local/bwrap>
106
+ }
107
+ EOF
108
+ sudo apparmor_parser -r /etc/apparmor.d/bwrap
109
+ bwrap --ro-bind / / --dev /dev --proc /proc --unshare-net true && echo "bubblewrap works"
110
+ ```
111
+
112
+ The broader option lifts the restriction for every program until the next reboot:
113
+ `sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0`.
114
+
115
+ `sandbox: off` in the settings runs the author session without the sandbox, as a person's choice. The Do the work form then says so.
116
+
117
+ ## Settings
118
+
119
+ A standalone tracker keeps these at the top of `core/config/plugin.<name>.settings.yml`; a forge plugin keeps them in its `tracker:` block.
120
+
121
+ | Key | Default | What it is |
122
+ | --- | --- | --- |
123
+ | `allow_writes` | `false` | Push and draft request, comment, worklog, move, labels, assign, create. Off: everything stays on this machine |
124
+ | `max_agents` | `1` | Author sessions at once, across the provider |
125
+ | `default_scope` | | The scope a project works against when it has none of its own (its remote, or a remembered one) |
126
+ | `scopes` | `[]` | The scopes the list may be switched to; empty is any |
127
+ | `work_in` | `branch` | `branch` in the project, or `worktree` outside the workspace folders |
128
+ | `sandbox` | `required` | `required`: no sandbox, no author session. `off`: a person's choice, said in the form |
129
+ | `network_domains` | `[]` | Domains the sandbox allows (the project's package registries) |
130
+ | `allow_web` | `false` | WebFetch and WebSearch in the author session |
131
+ | `comments_from` | `members` | The comments a snapshot keeps: `members`, `all`, `none` |
132
+ | `outsider_items` | `analyze` | An outsider's item: `analyze` (work it only after a confirmation that names them) or `refuse` |
133
+ | `draft` | `true` | Open requests as drafts |
134
+
135
+ ## Where things are kept
136
+
137
+ | Where | What |
138
+ | --- | --- |
139
+ | `specs/<ws>/<project>/NNN-<provider>-<item>-<slug>/` | `spec.yml`, `01-story.md`, `02-analysis.md`, `notes.md`, `work.diff`, `collaboration/` (the runs, `record.md` with "Decision (a person)") |
140
+ | `.screens/tracker/<session>/` | The session's `rules.md`, `prompt.md`, `settings.json`, `session.sh` (mode 600) and `run.json` (its note) |
141
+ | `<project>/.tracker-<provider>` | The scope a project remembers, kept out of git through `.git/info/exclude` |
142
+ | `.tracker/worktrees/<ws>/<project>/<provider>-<item>` | A worktree, removed from the Result tab; its branch stays |
143
+ | `core/workspace-app/actions.log` | A `tracker-write` line per write: provider, scope, item, write, who clicked, the account, the URL, ok |
144
+
145
+ ## Develop
146
+
147
+ ```bash
148
+ npm ci
149
+ npm run lint
150
+ npm test # node:test on the compiled TypeScript; git runs for real in temporary folders
151
+ ```
152
+
153
+ ## License
154
+
155
+ ISC (see `LICENSE`).
@@ -0,0 +1,13 @@
1
+ /* The tracker family's surface: the list, one item, the result and its previews. Only additions. */
2
+ .tracker-card .uk-label { vertical-align: middle; }
3
+ .tracker-key {
4
+ display: inline-block; padding: 0 .4em; border-radius: 4px; font-size: .75rem; line-height: 1.5;
5
+ background: var(--ws-accent-soft, rgba(30, 135, 240, .12)); color: inherit; text-decoration: none;
6
+ }
7
+ .tracker-key:hover { text-decoration: underline; }
8
+ .tracker-body, .tracker-notes {
9
+ white-space: pre-wrap; word-break: break-word; max-height: 24rem; overflow: auto; font-size: .8rem;
10
+ }
11
+ .tracker-outsider, .tracker-confirm { margin-top: .5rem; }
12
+ .tracker-preview textarea { font-family: var(--ws-mono, monospace); font-size: .8rem; }
13
+ .tracker-menu-head { text-transform: none; }
@@ -0,0 +1,53 @@
1
+ /**
2
+ * registerTracker(api, provider): the whole work-item surface of a tracker plugin, from a provider's facts.
3
+ *
4
+ * The menu (its own, or entries a forge puts in its menu), the list, one item with overview, analyze,
5
+ * do the work, result and runs, the writes a person may do from there (draft request, comment,
6
+ * worklog, move, labels, assign), the badge an agent at work puts on its card, the New-folder option,
7
+ * the settings options and what the assistant is told. What differs between trackers is in the provider.
8
+ *
9
+ * The rules this module keeps, everywhere:
10
+ * - a person starts every run, and an item from outside the project is analyze only unless a person
11
+ * confirms it by its author's name;
12
+ * - an AI session holds no token and never writes out: the dashboard does every write, after a preview
13
+ * a person can edit, only with writes on, and each write is a line in actions.log;
14
+ * - ticket text is data: it is written into the spec's 01-story.md (made visible, fenced) and never
15
+ * into a shell line or a prompt.
16
+ */
17
+ import type { FragmentContext, PluginApi, RowContext } from '@webship.co/workspace-plugin-api';
18
+ import type { TrackerProvider } from './provider';
19
+ import type { TrackerSettings } from './lib/settings';
20
+ export * from './provider';
21
+ export { auditWrite } from './lib/audit';
22
+ export { checkpoints, newItemBody, notesSection, requestBody, requestComment, sessionComment } from './lib/bodies';
23
+ export { BRANCH_RE, GIT_SAFE, gitOps, worktreeDir } from './lib/git';
24
+ export { parseRoles } from './lib/roles';
25
+ export { runsOf, sessionName, verbOf } from './lib/runs';
26
+ export { credentialPaths, DENIED_COMMANDS, rulesText, promptText, sessionSettings, TOKEN_VARIABLES } from './lib/session';
27
+ export { readTrackerSettings, SETTINGS_KEYS } from './lib/settings';
28
+ export type { TrackerSettings } from './lib/settings';
29
+ export { isInside, outsiderOf, storyText, writeSnapshot } from './lib/spec';
30
+ export { cap, fenced, fenceFor, oneLine, reveal, shq, slug, tokensIn } from './lib/text';
31
+ export interface TrackerOptions {
32
+ /** 'own': a row menu named for the provider (a standalone tracker); 'none': the caller shows `menuItems` in a menu of its own (a forge). */
33
+ menu?: 'own' | 'none';
34
+ /** The key of the tracker settings in the plugin's settings file ('tracker' in a forge plugin); '' for the top of the file. */
35
+ settingsBlock?: string;
36
+ /** The workspace-type action that must allow a row ('<provider id>' by default); null for every row. */
37
+ typeAction?: string | null;
38
+ /** Fragments of the plugin's own, for paths the base does not answer. */
39
+ fragment?: (ctx: FragmentContext) => unknown;
40
+ }
41
+ export interface TrackerHandle {
42
+ /**
43
+ * The menu entries for a row, for a forge's own menu: '' when the row has no scope here. `header: false` leaves out the
44
+ * heading line; `whenBlocked: 'none'` answers '' while the provider is not ready (no CLI, no token), so the forge keeps
45
+ * the entry it had before.
46
+ */
47
+ menuItems: (ctx: RowContext, opts?: {
48
+ header?: boolean;
49
+ whenBlocked?: 'disabled' | 'none';
50
+ }) => string;
51
+ settings: () => TrackerSettings;
52
+ }
53
+ export declare function registerTracker(api: PluginApi, p: TrackerProvider, options?: TrackerOptions): TrackerHandle;