@unbrained/pm-cli 2026.5.1-2 → 2026.5.2

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 (200) hide show
  1. package/CHANGELOG.md +15 -4
  2. package/CONTRIBUTING.md +11 -5
  3. package/PRD.md +17 -1
  4. package/README.md +49 -1101
  5. package/SECURITY.md +6 -11
  6. package/dist/cli/commands/activity.d.ts +10 -0
  7. package/dist/cli/commands/activity.js +13 -1
  8. package/dist/cli/commands/activity.js.map +1 -1
  9. package/dist/cli/commands/aggregate.js.map +1 -1
  10. package/dist/cli/commands/append.js.map +1 -1
  11. package/dist/cli/commands/calendar.js +16 -5
  12. package/dist/cli/commands/calendar.js.map +1 -1
  13. package/dist/cli/commands/claim.js.map +1 -1
  14. package/dist/cli/commands/close.js.map +1 -1
  15. package/dist/cli/commands/comments-audit.js.map +1 -1
  16. package/dist/cli/commands/comments.js.map +1 -1
  17. package/dist/cli/commands/completion.js.map +1 -1
  18. package/dist/cli/commands/config.js.map +1 -1
  19. package/dist/cli/commands/context.js +22 -0
  20. package/dist/cli/commands/context.js.map +1 -1
  21. package/dist/cli/commands/contracts.js.map +1 -1
  22. package/dist/cli/commands/create.js +2 -2
  23. package/dist/cli/commands/create.js.map +1 -1
  24. package/dist/cli/commands/dedupe-audit.js.map +1 -1
  25. package/dist/cli/commands/delete.js.map +1 -1
  26. package/dist/cli/commands/deps.js.map +1 -1
  27. package/dist/cli/commands/docs.js.map +1 -1
  28. package/dist/cli/commands/extension.js.map +1 -1
  29. package/dist/cli/commands/files.js.map +1 -1
  30. package/dist/cli/commands/gc.js.map +1 -1
  31. package/dist/cli/commands/get.js.map +1 -1
  32. package/dist/cli/commands/health.js +16 -12
  33. package/dist/cli/commands/health.js.map +1 -1
  34. package/dist/cli/commands/history.js.map +1 -1
  35. package/dist/cli/commands/index.js.map +1 -1
  36. package/dist/cli/commands/init.js.map +1 -1
  37. package/dist/cli/commands/learnings.js.map +1 -1
  38. package/dist/cli/commands/list.d.ts +1 -0
  39. package/dist/cli/commands/list.js +10 -2
  40. package/dist/cli/commands/list.js.map +1 -1
  41. package/dist/cli/commands/normalize.js +5 -17
  42. package/dist/cli/commands/normalize.js.map +1 -1
  43. package/dist/cli/commands/notes.js.map +1 -1
  44. package/dist/cli/commands/reindex.js.map +1 -1
  45. package/dist/cli/commands/restore.js.map +1 -1
  46. package/dist/cli/commands/search.js.map +1 -1
  47. package/dist/cli/commands/stats.js.map +1 -1
  48. package/dist/cli/commands/templates.js.map +1 -1
  49. package/dist/cli/commands/test-all.js.map +1 -1
  50. package/dist/cli/commands/test-runs.js.map +1 -1
  51. package/dist/cli/commands/test.js.map +1 -1
  52. package/dist/cli/commands/update-many.js +1 -6
  53. package/dist/cli/commands/update-many.js.map +1 -1
  54. package/dist/cli/commands/update.js +2 -2
  55. package/dist/cli/commands/update.js.map +1 -1
  56. package/dist/cli/commands/validate.js +11 -17
  57. package/dist/cli/commands/validate.js.map +1 -1
  58. package/dist/cli/error-guidance.js +13 -2
  59. package/dist/cli/error-guidance.js.map +1 -1
  60. package/dist/cli/extension-command-options.js.map +1 -1
  61. package/dist/cli/help-content.js.map +1 -1
  62. package/dist/cli/main.js +29 -13
  63. package/dist/cli/main.js.map +1 -1
  64. package/dist/cli.d.ts +1 -1
  65. package/dist/cli.js +3 -1
  66. package/dist/cli.js.map +1 -1
  67. package/dist/core/extensions/extension-types.d.ts +605 -0
  68. package/dist/core/extensions/extension-types.js +22 -0
  69. package/dist/core/extensions/extension-types.js.map +1 -0
  70. package/dist/core/extensions/index.js.map +1 -1
  71. package/dist/core/extensions/item-fields.js.map +1 -1
  72. package/dist/core/extensions/loader.d.ts +2 -586
  73. package/dist/core/extensions/loader.js +3 -21
  74. package/dist/core/extensions/loader.js.map +1 -1
  75. package/dist/core/extensions/runtime-registrations.js.map +1 -1
  76. package/dist/core/fs/fs-utils.js.map +1 -1
  77. package/dist/core/fs/index.js.map +1 -1
  78. package/dist/core/history/history-stream-policy.js.map +1 -1
  79. package/dist/core/history/history.js.map +1 -1
  80. package/dist/core/history/index.js.map +1 -1
  81. package/dist/core/item/id.js.map +1 -1
  82. package/dist/core/item/index.js.map +1 -1
  83. package/dist/core/item/item-format.js.map +1 -1
  84. package/dist/core/item/parent-reference-policy.js.map +1 -1
  85. package/dist/core/item/parse.js +6 -0
  86. package/dist/core/item/parse.js.map +1 -1
  87. package/dist/core/item/sprint-release-format.js.map +1 -1
  88. package/dist/core/item/status.js.map +1 -1
  89. package/dist/core/item/type-registry.js.map +1 -1
  90. package/dist/core/lock/index.js.map +1 -1
  91. package/dist/core/lock/lock.js +1 -6
  92. package/dist/core/lock/lock.js.map +1 -1
  93. package/dist/core/output/command-aware.js.map +1 -1
  94. package/dist/core/output/output.js.map +1 -1
  95. package/dist/core/schema/runtime-field-filters.js.map +1 -1
  96. package/dist/core/schema/runtime-field-values.js.map +1 -1
  97. package/dist/core/schema/runtime-schema.js.map +1 -1
  98. package/dist/core/search/cache.js +1 -7
  99. package/dist/core/search/cache.js.map +1 -1
  100. package/dist/core/search/embedding-batches.js +4 -0
  101. package/dist/core/search/embedding-batches.js.map +1 -1
  102. package/dist/core/search/providers.js +1 -20
  103. package/dist/core/search/providers.js.map +1 -1
  104. package/dist/core/search/semantic-defaults.js.map +1 -1
  105. package/dist/core/search/vector-stores.d.ts +1 -0
  106. package/dist/core/search/vector-stores.js +23 -27
  107. package/dist/core/search/vector-stores.js.map +1 -1
  108. package/dist/core/sentry/helpers.d.ts +6 -0
  109. package/dist/core/sentry/helpers.js +73 -0
  110. package/dist/core/sentry/helpers.js.map +1 -0
  111. package/dist/core/sentry/instrument.d.ts +4 -0
  112. package/dist/core/sentry/instrument.js +173 -0
  113. package/dist/core/sentry/instrument.js.map +1 -0
  114. package/dist/core/shared/command-types.js.map +1 -1
  115. package/dist/core/shared/conflict-markers.js.map +1 -1
  116. package/dist/core/shared/constants.js.map +1 -1
  117. package/dist/core/shared/errors.js.map +1 -1
  118. package/dist/core/shared/index.d.ts +1 -0
  119. package/dist/core/shared/index.js +1 -0
  120. package/dist/core/shared/index.js.map +1 -1
  121. package/dist/core/shared/primitives.d.ts +13 -0
  122. package/dist/core/shared/primitives.js +33 -0
  123. package/dist/core/shared/primitives.js.map +1 -0
  124. package/dist/core/shared/serialization.js.map +1 -1
  125. package/dist/core/shared/text-normalization.js.map +1 -1
  126. package/dist/core/shared/time.js.map +1 -1
  127. package/dist/core/store/index.js.map +1 -1
  128. package/dist/core/store/item-format-migration.js.map +1 -1
  129. package/dist/core/store/item-store.js +44 -35
  130. package/dist/core/store/item-store.js.map +1 -1
  131. package/dist/core/store/paths.js.map +1 -1
  132. package/dist/core/store/settings.js.map +1 -1
  133. package/dist/core/telemetry/consent.js.map +1 -1
  134. package/dist/core/telemetry/runtime.d.ts +2 -0
  135. package/dist/core/telemetry/runtime.js +40 -13
  136. package/dist/core/telemetry/runtime.js.map +1 -1
  137. package/dist/core/test/background-runs.js.map +1 -1
  138. package/dist/core/test/item-test-run-tracking.js.map +1 -1
  139. package/dist/sdk/cli-contracts.js.map +1 -1
  140. package/dist/sdk/index.d.ts +1 -1
  141. package/dist/sdk/index.js.map +1 -1
  142. package/dist/types/index.js.map +1 -1
  143. package/dist/types.js.map +1 -1
  144. package/docs/AGENT_GUIDE.md +125 -0
  145. package/docs/ARCHITECTURE.md +195 -478
  146. package/docs/COMMANDS.md +199 -0
  147. package/docs/CONFIGURATION.md +146 -0
  148. package/docs/EXTENSIONS.md +146 -645
  149. package/docs/QUICKSTART.md +108 -0
  150. package/docs/README.md +70 -0
  151. package/docs/RELEASING.md +50 -37
  152. package/docs/SDK.md +127 -68
  153. package/docs/TESTING.md +125 -0
  154. package/docs/examples/starter-extension/README.md +39 -25
  155. package/package.json +9 -1
  156. package/dist/command-types.d.ts +0 -1
  157. package/dist/command-types.js +0 -2
  158. package/dist/command-types.js.map +0 -1
  159. package/dist/constants.d.ts +0 -1
  160. package/dist/constants.js +0 -2
  161. package/dist/constants.js.map +0 -1
  162. package/dist/errors.d.ts +0 -1
  163. package/dist/errors.js +0 -2
  164. package/dist/errors.js.map +0 -1
  165. package/dist/fs-utils.d.ts +0 -1
  166. package/dist/fs-utils.js +0 -2
  167. package/dist/fs-utils.js.map +0 -1
  168. package/dist/history.d.ts +0 -1
  169. package/dist/history.js +0 -2
  170. package/dist/history.js.map +0 -1
  171. package/dist/id.d.ts +0 -1
  172. package/dist/id.js +0 -2
  173. package/dist/id.js.map +0 -1
  174. package/dist/item-format.d.ts +0 -1
  175. package/dist/item-format.js +0 -2
  176. package/dist/item-format.js.map +0 -1
  177. package/dist/item-store.d.ts +0 -1
  178. package/dist/item-store.js +0 -2
  179. package/dist/item-store.js.map +0 -1
  180. package/dist/lock.d.ts +0 -1
  181. package/dist/lock.js +0 -2
  182. package/dist/lock.js.map +0 -1
  183. package/dist/output.d.ts +0 -1
  184. package/dist/output.js +0 -2
  185. package/dist/output.js.map +0 -1
  186. package/dist/parse.d.ts +0 -1
  187. package/dist/parse.js +0 -2
  188. package/dist/parse.js.map +0 -1
  189. package/dist/paths.d.ts +0 -1
  190. package/dist/paths.js +0 -2
  191. package/dist/paths.js.map +0 -1
  192. package/dist/serialization.d.ts +0 -1
  193. package/dist/serialization.js +0 -2
  194. package/dist/serialization.js.map +0 -1
  195. package/dist/settings.d.ts +0 -1
  196. package/dist/settings.js +0 -2
  197. package/dist/settings.js.map +0 -1
  198. package/dist/time.d.ts +0 -1
  199. package/dist/time.js +0 -2
  200. package/dist/time.js.map +0 -1
@@ -0,0 +1,108 @@
1
+ # Quickstart
2
+
3
+ Use this page to get from a clean repository to a tracked, verified item.
4
+
5
+ ## Agent Quick Context
6
+
7
+ - Start with `pm init`.
8
+ - Create items with enough metadata to route work, then enrich later.
9
+ - Claim before implementation.
10
+ - Link changed files, docs, and tests to the item.
11
+ - Close only after evidence is recorded.
12
+
13
+ Tracked documentation work: [pm-1sb2](../.agents/pm/tasks/pm-1sb2.toon).
14
+
15
+ ## Install
16
+
17
+ ```bash
18
+ npm install -g @unbrained/pm-cli
19
+ pm --version
20
+ ```
21
+
22
+ For one-off use:
23
+
24
+ ```bash
25
+ npx @unbrained/pm-cli --help
26
+ ```
27
+
28
+ ## Initialize a Repository
29
+
30
+ ```bash
31
+ pm init
32
+ pm health --check-only
33
+ ```
34
+
35
+ `pm init` creates `.agents/pm/` with settings, item folders, history, locks, search cache directories, and project extension storage.
36
+
37
+ ## Create Your First Item
38
+
39
+ Use strict create mode when all required fields are ready. Use progressive mode for staged triage.
40
+
41
+ ```bash
42
+ pm create \
43
+ --title "Add restore retry logging" \
44
+ --description "Restore should explain stale lock retry behavior." \
45
+ --type Task \
46
+ --status open \
47
+ --priority 1 \
48
+ --tags "restore,locks" \
49
+ --ac "Retry logs are visible and regression coverage passes." \
50
+ --create-mode progressive
51
+ ```
52
+
53
+ Useful item types:
54
+
55
+ | Type | Use |
56
+ |------|-----|
57
+ | `Epic` | broad outcome or initiative |
58
+ | `Feature` | user-facing capability or major slice |
59
+ | `Task` | implementation work |
60
+ | `Issue` | bug or defect |
61
+ | `Decision` | recorded choice and rationale |
62
+ | `Event`, `Reminder`, `Milestone`, `Meeting` | calendar-aware planning |
63
+
64
+ ## Find and Claim Work
65
+
66
+ ```bash
67
+ pm context --limit 10
68
+ pm search "restore lock retry" --limit 10
69
+ pm list-open --limit 20
70
+ pm claim <item-id>
71
+ pm update <item-id> --status in_progress --message "Start implementation"
72
+ ```
73
+
74
+ Do not create a duplicate item until `context`, `search`, and list commands show no relevant active item.
75
+
76
+ ## Link Work Artifacts
77
+
78
+ ```bash
79
+ pm files <item-id> --add path=src/core/lock/lock.ts,scope=project,note="implementation"
80
+ pm docs <item-id> --add path=docs/ARCHITECTURE.md,scope=project,note="design context"
81
+ pm test <item-id> --add command="node scripts/run-tests.mjs test -- tests/unit/lock.spec.ts",scope=project,timeout_seconds=240
82
+ ```
83
+
84
+ Use `node scripts/run-tests.mjs ...` for linked tests so tracker data is sandboxed.
85
+
86
+ ## Record Evidence and Close
87
+
88
+ ```bash
89
+ pm test <item-id> --run --progress
90
+ pm comments <item-id> "Evidence: linked lock regression passed."
91
+ pm close <item-id> "Acceptance criteria met; linked regression passed." --validate-close warn
92
+ pm release <item-id>
93
+ ```
94
+
95
+ For broad readiness checks:
96
+
97
+ ```bash
98
+ pnpm build
99
+ node scripts/run-tests.mjs coverage
100
+ pm validate --check-resolution --check-history-drift
101
+ ```
102
+
103
+ ## Next Pages
104
+
105
+ - [Agent Guide](AGENT_GUIDE.md) for the full canonical workflow.
106
+ - [Command Reference](COMMANDS.md) for command families and examples.
107
+ - [Configuration](CONFIGURATION.md) for output, storage, search, and validation settings.
108
+ - [Testing](TESTING.md) for sandbox and linked-test details.
package/docs/README.md ADDED
@@ -0,0 +1,70 @@
1
+ # pm-cli Documentation
2
+
3
+ This directory is the public documentation home for `pm-cli`. It is organized for progressive disclosure: read the smallest page that answers the current question, then follow links only when more detail is needed.
4
+
5
+ ## Read Path
6
+
7
+ | Reader | First page | Then read |
8
+ |--------|------------|-----------|
9
+ | New user | [Quickstart](QUICKSTART.md) | [Command Reference](COMMANDS.md) |
10
+ | Coding agent | [Agent Guide](AGENT_GUIDE.md) | [Configuration](CONFIGURATION.md), then command help |
11
+ | Maintainer | [Contributing](../CONTRIBUTING.md) | [Testing](TESTING.md), [Releasing](RELEASING.md), [Architecture](ARCHITECTURE.md) |
12
+ | Extension author | [Extensions](EXTENSIONS.md) | [SDK](SDK.md), [starter extension](examples/starter-extension/README.md) |
13
+ | Machine client | [Command Reference](COMMANDS.md#machine-contracts) | `pm contracts --json` |
14
+
15
+ ## Documentation Map
16
+
17
+ - [Quickstart](QUICKSTART.md) - install, initialize, create, claim, link, test, close.
18
+ - [Agent Guide](AGENT_GUIDE.md) - canonical agent loop, tracker linking, and token-minimal command choices.
19
+ - [Command Reference](COMMANDS.md) - command families with examples and when to use each family.
20
+ - [Configuration](CONFIGURATION.md) - settings, storage formats, output, search, validation, and environment variables.
21
+ - [Testing](TESTING.md) - sandbox-safe local tests and linked-test orchestration.
22
+ - [Architecture](ARCHITECTURE.md) - contributor internals: storage, mutation flow, search, extensions, and command contracts.
23
+ - [Extensions](EXTENSIONS.md) - runtime extension lifecycle and API reference.
24
+ - [SDK](SDK.md) - public import surfaces and typed authoring examples.
25
+ - [Releasing](RELEASING.md) - maintainer release checklist and failure handling.
26
+ - [starter extension](examples/starter-extension/README.md) - compact extension scaffold reference.
27
+
28
+ Community files:
29
+
30
+ - [Contributing](../CONTRIBUTING.md)
31
+ - [Security](../SECURITY.md)
32
+ - [Code of Conduct](../CODE_OF_CONDUCT.md)
33
+ - [Changelog](../CHANGELOG.md)
34
+ - [License](../LICENSE)
35
+
36
+ ## Agent Routing Rules
37
+
38
+ 1. Start with [Agent Guide](AGENT_GUIDE.md) for workflow rules.
39
+ 2. Use [Command Reference](COMMANDS.md) for command families, not exhaustive flag memory.
40
+ 3. Use `pm <command> --help --json` or `pm contracts --command <name> --flags-only --json` for exact flags.
41
+ 4. Use [Architecture](ARCHITECTURE.md) only when changing internals or debugging behavior.
42
+ 5. Use [SDK](SDK.md) and [Extensions](EXTENSIONS.md) only when authoring or troubleshooting extensions.
43
+
44
+ ## Tracker References
45
+
46
+ This documentation structure is tracked through:
47
+
48
+ - [pm-3042](../.agents/pm/epics/pm-3042.toon)
49
+ - [pm-r9gu](../.agents/pm/features/pm-r9gu.toon)
50
+ - [pm-1sb2](../.agents/pm/tasks/pm-1sb2.toon)
51
+
52
+ When changing docs, link files back to the active item:
53
+
54
+ ```bash
55
+ pm docs <item-id> --add path=docs/README.md,scope=project,note="documentation index"
56
+ pm comments <item-id> "Docs updated; links and build verified."
57
+ ```
58
+
59
+ ## Public Boundary
60
+
61
+ Public docs must not link to ignored local operations artifacts, unpublished evidence logs, credentials, host-specific runbooks, or private service details. Keep those materials local and out of packaged releases.
62
+
63
+ ## Maintenance Checklist
64
+
65
+ - Keep links relative and GitHub-compatible.
66
+ - Keep README short; move detail into focused pages.
67
+ - Put a short "Agent Quick Context" near the top of deep docs.
68
+ - Prefer commands that agents can copy exactly.
69
+ - Use `pm` item IDs as durable references when docs explain tracked work.
70
+ - Run link/search checks before closing documentation tasks.
package/docs/RELEASING.md CHANGED
@@ -1,55 +1,66 @@
1
1
  # Releasing `@unbrained/pm-cli`
2
2
 
3
- This repository uses a tag-driven GitHub Actions pipeline that publishes to npm and creates a GitHub Release. The pipeline uses standard GitHub Actions, repository or environment secrets, artifacts, and npm provenance; it does not require paid GitHub features or paid-only environment protection rules.
3
+ This page is for maintainers cutting npm and GitHub releases. It assumes release work is tracked with `pm`.
4
4
 
5
- ## Version Policy
5
+ ## Agent Quick Context
6
+
7
+ - Release versioning is calendar SemVer-compatible: `YYYY.M.D` or `YYYY.M.D-N`.
8
+ - Publishing is owned by the GitHub Actions release workflow.
9
+ - Do not run manual `npm publish`.
10
+ - Run local gates before tagging.
6
11
 
7
- `pm-cli` uses a calendar SemVer-compatible scheme:
12
+ Tracked documentation work: [pm-1sb2](../.agents/pm/tasks/pm-1sb2.toon).
8
13
 
9
- - `YYYY.M.D` for the first release on a date
10
- - `YYYY.M.D-N` for additional releases on the same date (`N >= 2`)
14
+ ## Version Policy
11
15
 
12
16
  Examples:
13
17
 
14
- - First release on 2026-03-09: `2026.3.9`
15
- - Second release on 2026-03-09: `2026.3.9-2`
18
+ - first release on 2026-05-01: `2026.5.1`
19
+ - second release on 2026-05-01: `2026.5.1-2`
16
20
 
17
- Use this to compute the next expected release version from the npm registry:
21
+ Check the next version:
18
22
 
19
23
  ```bash
20
24
  pnpm version:next
21
25
  ```
22
26
 
23
- The release workflow enforces the package version, tag name, calendar date, and npm registry sequencing before publishing.
27
+ Validate the current package version:
28
+
29
+ ```bash
30
+ pnpm version:check
31
+ ```
24
32
 
25
33
  ## One-Time Setup
26
34
 
27
- - Add `NPM_TOKEN` as a GitHub Environment or repository secret named `NPM_TOKEN`.
28
- - If using an Environment named `release`, keep it free-feature compatible: no paid-only reviewer or deployment-protection requirements.
29
- - Ensure `GITHUB_TOKEN` has the default workflow permission needed by `permissions: contents: write` for GitHub Release creation.
30
- - Keep npm two-factor settings compatible with automation tokens and provenance publishing.
31
- - Keep `package.json` repository, homepage, and bugs URLs aligned with the canonical GitHub source repository (`https://github.com/unbraind/pm-cli`); npm provenance validation rejects mismatched repository metadata.
35
+ - Add `NPM_TOKEN` as a GitHub Environment or repository secret.
36
+ - Add `SENTRY_AUTH_TOKEN` as an optional GitHub Environment or repository secret when Sentry release creation and sourcemap upload should run. The release workflow skips this step cleanly when the secret is absent.
37
+ - Keep any `release` environment compatible with free GitHub features.
38
+ - Ensure `GITHUB_TOKEN` has `contents: write` for GitHub Release creation.
39
+ - Keep `package.json` repository, homepage, and bugs URLs aligned with `https://github.com/unbraind/pm-cli`.
40
+ - Keep npm automation token settings compatible with provenance publishing.
32
41
 
33
42
  ## Local Release Checklist
34
43
 
35
- 1. Confirm the next version:
44
+ 1. Confirm or compute the version.
36
45
 
37
46
  ```bash
38
47
  pnpm version:next
39
48
  ```
40
49
 
41
- 2. Update `package.json`, `pnpm-lock.yaml`, and `CHANGELOG.md`.
50
+ 2. Update release files.
42
51
 
43
- Keep direct dependency specifiers deterministic. Do not publish `latest` ranges; pin runtime and development dependencies to explicit SemVer ranges that resolve to the audited lockfile versions so Dependabot and downstream installs evaluate the same safe package line.
52
+ - `package.json`
53
+ - `pnpm-lock.yaml`
54
+ - [CHANGELOG.md](../CHANGELOG.md)
44
55
 
45
- 3. Generate release notes locally from changelog + pm tracker data:
56
+ 3. Generate release notes.
46
57
 
47
58
  ```bash
48
59
  pnpm build
49
60
  pnpm release:notes -- --version "$(node -p 'require("./package.json").version')" --output /tmp/pm-cli-release-notes.md
50
61
  ```
51
62
 
52
- 4. Run local release gates:
63
+ 4. Run local gates.
53
64
 
54
65
  ```bash
55
66
  pnpm install
@@ -63,9 +74,11 @@ pnpm security:scan
63
74
  pnpm smoke:npx
64
75
  ```
65
76
 
66
- 5. Verify previous-version tracker compatibility before tagging. Use a temporary project with the previously published package, create representative items, then run the current build against the same sandboxed `PM_PATH` and `PM_GLOBAL_PATH`. Confirm item count, fields, linked files/docs/tests, comments, close metadata, health, and history drift checks remain intact.
77
+ 5. Verify previous-version tracker compatibility in a temporary project.
67
78
 
68
- 6. Commit, push, tag, and push the tag:
79
+ Check representative items, linked files/docs/tests, comments, close metadata, health, and history drift across the previous package and current build.
80
+
81
+ 6. Commit, push, tag, and push the tag.
69
82
 
70
83
  ```bash
71
84
  git push origin main
@@ -73,22 +86,24 @@ git tag v<version>
73
86
  git push origin v<version>
74
87
  ```
75
88
 
76
- ## Release Workflow
89
+ ## GitHub Workflow
77
90
 
78
- `.github/workflows/release.yml` runs on `v*.*.*` tags and performs:
91
+ `.github/workflows/release.yml` runs on `v*.*.*` tags and handles:
79
92
 
80
- - full-history checkout for previous-tag and release-note generation
93
+ - full-history checkout
81
94
  - pnpm install with frozen lockfile
82
95
  - version policy and tag guard
83
- - secret leak scan
84
- - build, typecheck, test coverage, and sandboxed pm coverage
96
+ - secret scan
97
+ - build, typecheck, test, and coverage
98
+ - sandboxed `pm` coverage
99
+ - optional Sentry release metadata and sourcemap upload when `SENTRY_AUTH_TOKEN` is configured
85
100
  - npm pack dry run and npx tarball smoke test
86
- - generated release notes from `CHANGELOG.md` plus sanitized `pm` tracker metadata
87
- - coverage and release-note artifact uploads
101
+ - generated release notes from changelog plus sanitized tracker metadata
102
+ - artifact uploads
88
103
  - `npm publish --access public --provenance`
89
- - GitHub Release creation using the generated release-note body
104
+ - GitHub Release creation
90
105
 
91
- Monitor with:
106
+ Monitor:
92
107
 
93
108
  ```bash
94
109
  gh run list --workflow Release --limit 5
@@ -97,8 +112,6 @@ gh run watch <run-id> --exit-status
97
112
 
98
113
  ## Post-Release Verification
99
114
 
100
- After the workflow succeeds, verify all distribution paths:
101
-
102
115
  ```bash
103
116
  npm view @unbrained/pm-cli@<version> version dist.integrity dist.unpackedSize --json
104
117
  npx --yes @unbrained/pm-cli@<version> --version
@@ -106,11 +119,11 @@ bunx @unbrained/pm-cli@<version> --version
106
119
  gh release view v<version> --json tagName,name,isDraft,isPrerelease,url
107
120
  ```
108
121
 
109
- The `pm` executable name remains unchanged even though the npm package is scoped.
122
+ The executable remains `pm` even though the npm package is scoped.
110
123
 
111
124
  ## Failure Handling
112
125
 
113
- - Do not run manual `npm publish`; publishing is owned by `.github/workflows/release.yml`.
114
- - If local gates fail, fix the code/docs/tests and rerun the checklist before tagging.
115
- - If the tag workflow fails before npm publish, fix the issue, move the tag only after confirming no package was published, and rerun the workflow.
116
- - If npm publish succeeds but GitHub Release creation fails, rerun only the release creation after confirming the tag and package are correct.
126
+ - If local gates fail, fix and rerun before tagging.
127
+ - If the tag workflow fails before npm publish, confirm no package was published before moving or replacing a tag.
128
+ - If npm publish succeeds but GitHub Release creation fails, recreate only the GitHub Release after verifying the tag and package.
129
+ - Record failure evidence and remediation in the release `pm` item.
package/docs/SDK.md CHANGED
@@ -1,123 +1,182 @@
1
- # pm SDK Guide
1
+ # SDK
2
2
 
3
- This guide documents the public SDK surface for extension authors.
3
+ The public SDK is exported from `@unbrained/pm-cli/sdk`. Use it for extension authoring and command-contract introspection. Do not import internal `src/core/...` modules from extensions.
4
4
 
5
- Primary import:
5
+ ## Agent Quick Context
6
+
7
+ - Primary import: `@unbrained/pm-cli/sdk`.
8
+ - Runtime extension lifecycle is documented in [Extensions](EXTENSIONS.md).
9
+ - Exact command/action contracts are available through `pm contracts`.
10
+
11
+ Tracked documentation work: [pm-1sb2](../.agents/pm/tasks/pm-1sb2.toon).
12
+
13
+ ## Import Surfaces
6
14
 
7
15
  ```ts
8
16
  import { defineExtension } from "@unbrained/pm-cli/sdk";
9
17
  ```
10
18
 
11
- Use this document for SDK/API contracts. Use `docs/EXTENSIONS.md` for full runtime lifecycle behavior and `pm extension --init ./my-extension` for starter scaffold generation.
12
-
13
- ## Import Surfaces
19
+ Supported package exports:
14
20
 
15
- - `@unbrained/pm-cli/sdk`: stable extension authoring API and CLI contract exports.
16
- - `@unbrained/pm-cli/cli`: runtime CLI module entrypoint. This path is for runtime module resolution, not a typed library API; its declaration file intentionally exports no symbols.
21
+ - `@unbrained/pm-cli/sdk` - stable extension authoring API and CLI contract exports.
22
+ - `@unbrained/pm-cli/cli` - runtime CLI module entrypoint for package resolution, not a typed library API.
17
23
 
18
- ## Public SDK Exports
24
+ ## Public Exports
19
25
 
20
26
  Source of truth:
21
27
 
22
- - `src/sdk/index.ts`
23
- - `src/sdk/cli-contracts.ts`
28
+ - [`src/sdk/index.ts`](../src/sdk/index.ts)
29
+ - [`src/sdk/cli-contracts.ts`](../src/sdk/cli-contracts.ts)
24
30
 
25
- ### Extension authoring values
31
+ Common authoring exports:
26
32
 
27
- - `defineExtension(...)`
33
+ - `defineExtension`
28
34
  - `EXTENSION_CAPABILITIES`
29
35
  - `EXTENSION_CAPABILITY_CONTRACT`
30
36
  - `EXTENSION_CAPABILITY_CONTRACT_VERSION`
31
37
  - `EXTENSION_CAPABILITY_LEGACY_ALIASES`
32
-
33
- ### CLI/action contract values
34
-
35
38
  - `PM_CORE_COMMAND_NAMES`
36
39
  - `PM_TOOL_ACTIONS`
37
40
  - `PM_TOOL_PARAMETERS_SCHEMA`
38
41
  - `PM_EXTENSION_CAPABILITY_CONTRACTS`
39
42
  - `PM_EXTENSION_SERVICE_NAME_CONTRACTS`
40
- - all exported `...FLAG_CONTRACTS`, `...OPTION_CONTRACTS`, and `...COMMANDER_*_CONTRACTS` arrays from `src/sdk/cli-contracts.ts`
41
-
42
- ### CLI/action contract helpers
43
-
44
- - `withFlagAliasMetadata(...)`
45
- - `toCompletionFlagString(...)`
46
- - `readFirstStringFromCommanderOptions(...)`
47
- - `readStringArrayFromCommanderOptions(...)`
48
43
 
49
- ### Key type exports
44
+ Common types:
50
45
 
51
- - extension capability/types: `ExtensionCapability`, `PmToolAction`, `PmExtensionCapabilityContract`, `PmExtensionServiceNameContract`
52
- - command/flag/type helpers: `CommandDefinition`, `ExtensionCommandArgumentDefinition`, `FlagDefinition`, `SchemaFieldDefinition`, `SchemaItemTypeDefinition`
53
- - runtime extension API types: `ExtensionApi`, `ExtensionManifest`, lifecycle hook context types, importer/exporter contexts, search provider types, vector adapter types
54
- - shared command/settings types: `GlobalOptions`, `PmSettings`
55
-
56
- ## Capability Requirements (Quick Reference)
57
-
58
- Declare capabilities in `manifest.json`; runtime gating is strict.
46
+ - `ExtensionApi`
47
+ - `ExtensionManifest`
48
+ - `CommandDefinition`
49
+ - `FlagDefinition`
50
+ - `SchemaFieldDefinition`
51
+ - `SchemaItemTypeDefinition`
52
+ - `SearchProviderDefinition`
53
+ - `VectorStoreAdapterDefinition`
54
+ - `GlobalOptions`
55
+ - `PmSettings`
56
+
57
+ ## Capability Requirements
58
+
59
+ | Registration | Manifest capability |
60
+ |--------------|---------------------|
61
+ | `registerCommand` | `commands` |
62
+ | inline command flags | `schema` |
63
+ | `registerFlags` | `schema` |
64
+ | `registerItemFields` | `schema` |
65
+ | `registerItemTypes` | `schema` |
66
+ | `registerMigration` | `schema` |
67
+ | `registerImporter` | `importers` |
68
+ | `registerExporter` | `importers` |
69
+ | `registerParser` | `parser` |
70
+ | `registerPreflight` | `preflight` |
71
+ | `registerService` | `services` |
72
+ | `registerRenderer` | `renderers` |
73
+ | lifecycle hooks | `hooks` |
74
+ | `registerSearchProvider` | `search` |
75
+ | `registerVectorStoreAdapter` | `search` |
76
+
77
+ ## Minimal Command Extension
59
78
 
60
- - `registerCommand(...)`: requires `commands`
61
- - `registerCommand({ flags: [...] })` and `registerFlags(...)`: require `schema`
62
- - `registerItemFields(...)`, `registerItemTypes(...)`, `registerMigration(...)`: require `schema`
63
- - `registerImporter(...)` and `registerExporter(...)`: require `importers`
64
- - `registerParser(...)`: requires `parser`
65
- - `registerPreflight(...)`: requires `preflight`
66
- - `registerService(...)`: requires `services`
67
- - `registerRenderer(...)`: requires `renderers`
68
- - lifecycle hooks (`beforeCommand`, `afterCommand`, `onWrite`, `onRead`, `onIndex`): require `hooks`
69
- - `registerSearchProvider(...)` and `registerVectorStoreAdapter(...)`: require `search`
79
+ ```ts
80
+ import { defineExtension } from "@unbrained/pm-cli/sdk";
70
81
 
71
- ## Minimal Extension
82
+ export default defineExtension({
83
+ activate(api) {
84
+ api.registerCommand({
85
+ name: "hello",
86
+ description: "Return a deterministic hello payload.",
87
+ intent: "verify SDK extension activation",
88
+ examples: ["pm hello"],
89
+ run: async () => ({ ok: true, message: "hello" }),
90
+ });
91
+ },
92
+ });
93
+ ```
72
94
 
73
- `manifest.json`:
95
+ Manifest:
74
96
 
75
97
  ```json
76
98
  {
77
- "name": "hello-extension",
99
+ "name": "hello",
78
100
  "version": "0.1.0",
79
101
  "entry": "./index.js",
80
102
  "capabilities": ["commands"]
81
103
  }
82
104
  ```
83
105
 
84
- `index.js`:
106
+ ## Custom Item Type
85
107
 
86
- ```js
108
+ ```ts
87
109
  import { defineExtension } from "@unbrained/pm-cli/sdk";
88
110
 
89
111
  export default defineExtension({
90
112
  activate(api) {
91
- api.registerCommand({
92
- name: "hello",
93
- run: async () => ({ ok: true, message: "hello from sdk extension" }),
113
+ api.registerItemTypes([
114
+ {
115
+ name: "Incident",
116
+ folder: "incidents",
117
+ aliases: ["incident"],
118
+ required_create_fields: ["title", "description", "severity"],
119
+ options: [
120
+ { key: "severity", values: ["critical", "major", "minor"], required: true },
121
+ { key: "service", values: ["api", "web", "worker"] },
122
+ ],
123
+ },
124
+ ]);
125
+
126
+ api.registerItemFields([
127
+ { name: "severity", type: "string" },
128
+ { name: "service", type: "string", optional: true },
129
+ ]);
130
+ },
131
+ });
132
+ ```
133
+
134
+ Manifest capability: `schema`.
135
+
136
+ ## Search Provider
137
+
138
+ ```ts
139
+ import { defineExtension } from "@unbrained/pm-cli/sdk";
140
+
141
+ export default defineExtension({
142
+ activate(api) {
143
+ api.registerSearchProvider({
144
+ name: "example-search",
145
+ async query(context) {
146
+ return context.documents
147
+ .filter((doc) => doc.front_matter.title?.toLowerCase().includes(context.query.toLowerCase()))
148
+ .map((doc) => ({ id: doc.front_matter.id, score: 0.5, matched_fields: ["title"] }));
149
+ },
94
150
  });
95
151
  },
96
152
  });
97
153
  ```
98
154
 
99
- ## Typed Authoring Highlights
155
+ Manifest capability: `search`.
100
156
 
101
- The SDK provides explicit interfaces for key surfaces including:
157
+ ## Command Contracts
102
158
 
103
- - `CommandDefinition` and `ExtensionCommandArgumentDefinition`
104
- - `FlagDefinition`
105
- - `SchemaFieldDefinition`, `SchemaItemTypeDefinition`, `SchemaMigrationDefinition`
106
- - `ImportExportContext`
107
- - `SearchProviderDefinition`, `SearchProviderQueryContext`, `SearchProviderHit`
108
- - `VectorStoreAdapterDefinition`, `VectorStoreQueryContext`, `VectorStoreUpsertContext`
159
+ For machine clients:
160
+
161
+ ```bash
162
+ pm contracts --json
163
+ pm contracts --command create --flags-only --json
164
+ pm contracts --action create --schema-only --json
165
+ ```
109
166
 
110
- These interfaces intentionally allow additive metadata (`[key: string]: unknown`) where extension-defined metadata is expected.
167
+ Use the runtime command because active extensions can add command/action metadata.
111
168
 
112
- ## Recommended Authoring Pattern
169
+ ## Authoring Pattern
113
170
 
114
- - keep command handlers deterministic and JSON-like
115
- - keep renderer/service overrides narrow to specific command paths
116
- - prefer additive hooks and schema fields over global behavior changes
117
- - ship one extension folder with `manifest.json`, an entry module, and package metadata/dependencies
171
+ - Keep handlers deterministic and JSON-like.
172
+ - Return data, not pre-rendered terminal text, unless implementing a renderer.
173
+ - Keep service and preflight overrides narrow.
174
+ - Declare only capabilities in use.
175
+ - Include examples and failure hints in dynamic commands.
176
+ - Add `pm extension doctor` diagnostics to testing instructions.
118
177
 
119
178
  ## Related Docs
120
179
 
121
- - full extension lifecycle/runtime reference: `docs/EXTENSIONS.md`
122
- - architecture internals: `docs/ARCHITECTURE.md`
123
- - complete starter scaffold: `docs/examples/starter-extension/`
180
+ - [Extensions](EXTENSIONS.md)
181
+ - [Architecture](ARCHITECTURE.md)
182
+ - [starter extension](examples/starter-extension/README.md)