pi-ui-extend 1.0.40 → 1.0.42

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 (186) hide show
  1. package/README.md +10 -2
  2. package/dist/app/app.d.ts +3 -0
  3. package/dist/app/app.js +26 -0
  4. package/dist/app/commands/command-host.d.ts +1 -0
  5. package/dist/app/commands/command-model-actions.js +6 -1
  6. package/dist/app/commands/command-registry.js +3 -3
  7. package/dist/app/commands/command-session-actions.d.ts +0 -1
  8. package/dist/app/commands/command-session-actions.js +30 -15
  9. package/dist/app/commands/reload-context-inventory.d.ts +11 -0
  10. package/dist/app/commands/reload-context-inventory.js +59 -0
  11. package/dist/app/extensions/extension-actions-controller.d.ts +1 -0
  12. package/dist/app/extensions/extension-actions-controller.js +6 -0
  13. package/dist/app/extensions/subagent-catalog-state.d.ts +9 -0
  14. package/dist/app/extensions/subagent-catalog-state.js +23 -0
  15. package/dist/app/icons.d.ts +14 -0
  16. package/dist/app/icons.js +33 -0
  17. package/dist/app/rendering/conversation-tool-renderer.js +2 -2
  18. package/dist/app/rendering/dcp-stats.d.ts +6 -1
  19. package/dist/app/rendering/dcp-stats.js +214 -46
  20. package/dist/app/rendering/editor-panels.js +17 -8
  21. package/dist/app/session/lazy-session-manager.js +12 -1
  22. package/dist/app/session/session-lifecycle-controller.d.ts +1 -0
  23. package/dist/app/session/session-lifecycle-controller.js +6 -0
  24. package/dist/app/session/tabs-controller.d.ts +3 -5
  25. package/dist/app/session/tabs-controller.js +31 -22
  26. package/dist/app/subagents/subagents-files.js +60 -1
  27. package/dist/app/subagents/subagents-model.d.ts +15 -1
  28. package/dist/app/subagents/subagents-model.js +52 -17
  29. package/dist/app/types.d.ts +7 -0
  30. package/dist/bundled-extensions/session-title/config.js +1 -1
  31. package/dist/default-pix-config.js +10 -0
  32. package/dist/markdown-format.js +27 -9
  33. package/dist/schemas/index.d.ts +1 -0
  34. package/dist/schemas/index.js +1 -0
  35. package/dist/schemas/pi-tools-suite-schema.d.ts +106 -71
  36. package/dist/schemas/pi-tools-suite-schema.js +68 -88
  37. package/dist/schemas/pix-schema.d.ts +7 -0
  38. package/dist/schemas/pix-schema.js +14 -0
  39. package/dist/schemas/tasks-schema.d.ts +18 -0
  40. package/dist/schemas/tasks-schema.js +41 -0
  41. package/docs/concurrency.md +6 -0
  42. package/docs/desktop-mvp.md +12 -1
  43. package/docs/desktop-task-manager.md +93 -82
  44. package/external/pi-tools-suite/README.md +192 -72
  45. package/external/pi-tools-suite/docs/browser-qa-subagent.md +50 -21
  46. package/external/pi-tools-suite/docs/context-gateway-p00-adr.md +216 -0
  47. package/external/pi-tools-suite/docs/context-gateway-p01n-gate-review.md +122 -0
  48. package/external/pi-tools-suite/docs/context-gateway-p01n-measurement.md +133 -0
  49. package/external/pi-tools-suite/docs/context-gateway-p01r-ra-evidence.md +111 -0
  50. package/external/pi-tools-suite/docs/context-gateway-p01r-rb-evidence.md +100 -0
  51. package/external/pi-tools-suite/docs/context-gateway-p01r-rc-evidence.md +69 -0
  52. package/external/pi-tools-suite/docs/context-gateway-p01r-rd-evidence.md +100 -0
  53. package/external/pi-tools-suite/docs/context-gateway-p01r-re-evidence.md +74 -0
  54. package/external/pi-tools-suite/docs/context-gateway-p01r-rf-evidence.md +153 -0
  55. package/external/pi-tools-suite/docs/context-gateway-p01r-rg-evidence.md +235 -0
  56. package/external/pi-tools-suite/docs/evals.md +1 -1
  57. package/external/pi-tools-suite/docs/session-recovery.md +40 -14
  58. package/external/pi-tools-suite/docs/subagent-model-pools.md +120 -0
  59. package/external/pi-tools-suite/package.json +3 -0
  60. package/external/pi-tools-suite/src/async-subagents/{private-skills → agents}/browser-qa/scripts/browser-qa-runner.mjs +82 -1
  61. package/external/pi-tools-suite/src/async-subagents/{private-skills/browser-qa/SKILL.md → agents/browser-qa.md} +261 -12
  62. package/external/pi-tools-suite/src/async-subagents/agents/frontier-review.md +23 -0
  63. package/external/pi-tools-suite/src/async-subagents/agents/implement.md +20 -0
  64. package/external/pi-tools-suite/src/async-subagents/agents/oracle.md +16 -0
  65. package/external/pi-tools-suite/src/async-subagents/agents/presets.jsonc +16 -0
  66. package/external/pi-tools-suite/src/async-subagents/agents/research.md +20 -0
  67. package/external/pi-tools-suite/src/async-subagents/agents/verify.md +18 -0
  68. package/external/pi-tools-suite/src/async-subagents/commands.ts +20 -72
  69. package/external/pi-tools-suite/src/async-subagents/core/activity.ts +33 -0
  70. package/external/pi-tools-suite/src/async-subagents/core/agent-catalog.ts +42 -0
  71. package/external/pi-tools-suite/src/async-subagents/core/agent-strategy.ts +13 -93
  72. package/external/pi-tools-suite/src/async-subagents/core/agents-dir.ts +499 -0
  73. package/external/pi-tools-suite/src/async-subagents/core/browser-qa.ts +9 -0
  74. package/external/pi-tools-suite/src/async-subagents/core/config.ts +284 -417
  75. package/external/pi-tools-suite/src/async-subagents/core/model-fallback.ts +1 -1
  76. package/external/pi-tools-suite/src/async-subagents/core/model-selection.ts +54 -0
  77. package/external/pi-tools-suite/src/async-subagents/core/prompt.ts +7 -6
  78. package/external/pi-tools-suite/src/async-subagents/core/routing.ts +65 -45
  79. package/external/pi-tools-suite/src/async-subagents/core/spawn.ts +18 -6
  80. package/external/pi-tools-suite/src/async-subagents/core/state.ts +40 -0
  81. package/external/pi-tools-suite/src/async-subagents/core/types.ts +7 -0
  82. package/external/pi-tools-suite/src/async-subagents/index.ts +77 -3
  83. package/external/pi-tools-suite/src/async-subagents/lib.ts +12 -9
  84. package/external/pi-tools-suite/src/async-subagents/tools/spawn.ts +54 -22
  85. package/external/pi-tools-suite/src/async-subagents/tools/subagents.ts +6 -4
  86. package/external/pi-tools-suite/src/async-subagents/types.ts +3 -0
  87. package/external/pi-tools-suite/src/config.ts +42 -2
  88. package/external/pi-tools-suite/src/context-gateway/accounting.ts +151 -0
  89. package/external/pi-tools-suite/src/context-gateway/config.ts +120 -0
  90. package/external/pi-tools-suite/src/context-gateway/enforcement.ts +102 -0
  91. package/external/pi-tools-suite/src/context-gateway/index.ts +214 -0
  92. package/external/pi-tools-suite/src/context-gateway/metadata-normalization.ts +88 -0
  93. package/external/pi-tools-suite/src/context-gateway/storeless-capabilities.ts +89 -0
  94. package/external/pi-tools-suite/src/context-gateway/telemetry.ts +502 -0
  95. package/external/pi-tools-suite/src/context-gateway/test-output-parser.ts +326 -0
  96. package/external/pi-tools-suite/src/context-gateway/types.ts +158 -0
  97. package/external/pi-tools-suite/src/context-inventory.ts +99 -0
  98. package/external/pi-tools-suite/src/dcp/auto-compress-budget.ts +106 -0
  99. package/external/pi-tools-suite/src/dcp/auto-compress.ts +892 -136
  100. package/external/pi-tools-suite/src/dcp/commands.ts +82 -139
  101. package/external/pi-tools-suite/src/dcp/compress-tool.ts +533 -74
  102. package/external/pi-tools-suite/src/dcp/compression-blocks.ts +488 -94
  103. package/external/pi-tools-suite/src/dcp/compression-preview.ts +122 -0
  104. package/external/pi-tools-suite/src/dcp/compression-progress.ts +70 -0
  105. package/external/pi-tools-suite/src/dcp/config.ts +86 -68
  106. package/external/pi-tools-suite/src/dcp/conversation-index.ts +421 -0
  107. package/external/pi-tools-suite/src/dcp/debug-log.ts +7 -5
  108. package/external/pi-tools-suite/src/dcp/index.ts +617 -203
  109. package/external/pi-tools-suite/src/dcp/journal.ts +566 -0
  110. package/external/pi-tools-suite/src/dcp/progress-controller.ts +244 -0
  111. package/external/pi-tools-suite/src/dcp/prompts.ts +83 -189
  112. package/external/pi-tools-suite/src/dcp/protected-continuity.ts +175 -0
  113. package/external/pi-tools-suite/src/dcp/provider-tool-results.ts +189 -0
  114. package/external/pi-tools-suite/src/dcp/pruner-candidates.ts +299 -79
  115. package/external/pi-tools-suite/src/dcp/pruner-compression-blocks.ts +173 -281
  116. package/external/pi-tools-suite/src/dcp/pruner-emergency.ts +2 -4
  117. package/external/pi-tools-suite/src/dcp/pruner-message-ids.ts +23 -15
  118. package/external/pi-tools-suite/src/dcp/pruner-metadata.ts +11 -1
  119. package/external/pi-tools-suite/src/dcp/pruner-nudge.ts +30 -82
  120. package/external/pi-tools-suite/src/dcp/pruner-tools.ts +28 -136
  121. package/external/pi-tools-suite/src/dcp/pruner.ts +18 -33
  122. package/external/pi-tools-suite/src/dcp/recovery.ts +129 -0
  123. package/external/pi-tools-suite/src/dcp/shadow-plan.ts +127 -0
  124. package/external/pi-tools-suite/src/dcp/state-transaction.ts +102 -0
  125. package/external/pi-tools-suite/src/dcp/state.ts +158 -580
  126. package/external/pi-tools-suite/src/dcp/ui.ts +1 -0
  127. package/external/pi-tools-suite/src/default-pi-tools-suite-config.ts +36 -214
  128. package/external/pi-tools-suite/src/index.ts +16 -1
  129. package/external/pi-tools-suite/src/model-tools/index.ts +76 -42
  130. package/external/pi-tools-suite/src/repo-discovery/index.ts +84 -18
  131. package/external/pi-tools-suite/src/repo-discovery/native-compact.ts +458 -0
  132. package/external/pi-tools-suite/src/resource-registry/index.ts +2290 -0
  133. package/external/pi-tools-suite/src/session-recovery/index.ts +189 -43
  134. package/external/pi-tools-suite/src/shell-command-policy.ts +219 -0
  135. package/external/pi-tools-suite/src/tool-descriptions.ts +41 -38
  136. package/external/pi-tools-suite/src/truncation-metadata-normalizer/index.ts +17 -0
  137. package/package.json +6 -3
  138. package/schemas/pi-tools-suite.json +540 -312
  139. package/schemas/pix.json +24 -0
  140. package/schemas/tasks.json +132 -0
  141. package/skills/spec-wiki/SKILL.md +55 -0
  142. package/skills/spec-wiki/evals/evals.json +132 -0
  143. package/skills/spec-wiki/evals/files/bootstrap/architecture/rfc-007.md +14 -0
  144. package/skills/spec-wiki/evals/files/bootstrap/docs/how-to-pay.md +4 -0
  145. package/skills/spec-wiki/evals/files/bootstrap/docs/overview.md +9 -0
  146. package/skills/spec-wiki/evals/files/bootstrap/requirements/payment-behavior.md +17 -0
  147. package/skills/spec-wiki/evals/files/bootstrap/src/payments.ts +12 -0
  148. package/skills/spec-wiki/evals/files/bootstrap/tests/payments.test.ts +11 -0
  149. package/skills/spec-wiki/evals/files/focused/src/session.ts +5 -0
  150. package/skills/spec-wiki/evals/files/focused/tests/session.test.ts +17 -0
  151. package/skills/spec-wiki/evals/files/maintenance/low-signal/incoming/capture.txt +2 -0
  152. package/skills/spec-wiki/evals/files/maintenance/low-signal/src/capture.ts +3 -0
  153. package/skills/spec-wiki/evals/files/maintenance/move/docs/old-job-contract.md +18 -0
  154. package/skills/spec-wiki/evals/files/maintenance/move/src/job.ts +5 -0
  155. package/skills/spec-wiki/evals/files/maintenance/new-relation/docs/session-refresh.md +24 -0
  156. package/skills/spec-wiki/evals/files/maintenance/new-relation/incoming/refresh-worker.ts +7 -0
  157. package/skills/spec-wiki/evals/files/maintenance/new-relation/src/session.ts +7 -0
  158. package/skills/spec-wiki/evals/files/maintenance/no-impact/docs/auth-contract.md +17 -0
  159. package/skills/spec-wiki/evals/files/maintenance/no-impact/incoming/telemetry-format.ts +3 -0
  160. package/skills/spec-wiki/evals/files/maintenance/no-impact/src/auth.ts +3 -0
  161. package/skills/spec-wiki/evals/files/query/docs/how-to-run-jobs.md +4 -0
  162. package/skills/spec-wiki/evals/files/query/docs/spec-overview.md +9 -0
  163. package/skills/spec-wiki/evals/files/query/features/jobs/cancellation-contract.md +15 -0
  164. package/skills/spec-wiki/evals/files/query/features/jobs/retry-spec.md +6 -0
  165. package/skills/spec-wiki/evals/maintenance_regression.py +311 -0
  166. package/skills/spec-wiki/evals/retrieval-eval.md +37 -0
  167. package/skills/spec-wiki/evals/retrieval-evals.json +37 -0
  168. package/skills/spec-wiki/evals/trigger-evals.json +94 -0
  169. package/skills/spec-wiki/references/bootstrap.md +100 -0
  170. package/skills/spec-wiki/references/focused-spec.md +117 -0
  171. package/skills/spec-wiki/references/index-schema.md +330 -0
  172. package/skills/spec-wiki/references/maintenance.md +134 -0
  173. package/skills/spec-wiki/references/query.md +74 -0
  174. package/skills/spec-wiki/scripts/spec_wiki.py +2076 -0
  175. package/docs/desktop-markdown-media.md +0 -77
  176. package/external/pi-tools-suite/docs/dcp-emergency-current-turn.md +0 -102
  177. package/external/pi-tools-suite/src/async-subagents/async-subagents.sample.jsonc +0 -270
  178. package/external/pi-tools-suite/src/async-subagents/private-skills/browser-qa/references/auth-scaffold-spec.md +0 -78
  179. package/external/pi-tools-suite/src/async-subagents/private-skills/browser-qa/references/qa-design.md +0 -223
  180. package/external/pi-tools-suite/src/dcp/state-persistence.ts +0 -195
  181. package/external/pi-tools-suite/src/skill-installer/index.ts +0 -333
  182. package/skills/spec-lite/SKILL.md +0 -140
  183. /package/external/pi-tools-suite/src/async-subagents/{private-skills/browser-qa/references → agents/browser-qa/examples}/qa-auth.example.jsonc +0 -0
  184. /package/external/pi-tools-suite/src/async-subagents/{private-skills/browser-qa/references → agents/browser-qa/examples}/qa-flow.example.jsonc +0 -0
  185. /package/external/pi-tools-suite/src/async-subagents/{private-skills → agents}/browser-qa/vendor/fflate.LICENSE +0 -0
  186. /package/external/pi-tools-suite/src/async-subagents/{private-skills → agents}/browser-qa/vendor/fflate.mjs +0 -0
@@ -0,0 +1,117 @@
1
+ # Focused spec work
2
+
3
+ Use this workflow for creating, updating, or checking one primary spec. Keep the
4
+ scope narrow; repository-wide indexing is optional unless it helps retrieval.
5
+
6
+ ## Core rules
7
+
8
+ - Do not change production code unless implementation was requested.
9
+ - Do not invent behavior. Mark ambiguity as inferred or unknown.
10
+ - Prefer compact specs over exhaustive design documents.
11
+ - Read only relevant code, tests, schemas, migrations, entrypoints, docs, and
12
+ existing specs.
13
+ - Follow the project's existing documentation convention when one exists.
14
+ - Describe current behavior as `as-is`; intended behavior as `change`.
15
+
16
+ ## When a spec is useful
17
+
18
+ Prefer a focused spec for changes involving security/auth/privacy, data or
19
+ persistence, public APIs/CLI/UI/events, integrations, destructive operations,
20
+ async/concurrency/retries, cross-cutting architecture, non-trivial user-visible
21
+ edge cases, unclear bug-fix contracts, or suspected spec-code drift.
22
+
23
+ Do not force a spec for formatting-only edits, mechanical renames, or obvious
24
+ local changes without broader behavioral impact.
25
+
26
+ ## As-is / drift workflow
27
+
28
+ 1. Identify the narrow behavior or contract.
29
+ 2. If a Spec Wiki already exists, use it only to locate related primary specs.
30
+ 3. Inspect the relevant code, tests, docs, schemas, migrations, and entrypoints.
31
+ 4. Separate claims as:
32
+ - confirmed by code;
33
+ - confirmed by tests;
34
+ - confirmed by docs;
35
+ - inferred;
36
+ - unknown.
37
+ 5. Write/update a compact as-is spec.
38
+ 6. Report detected drift separately from confirmed behavior.
39
+ 7. If the project uses Spec Wiki, `record` the spec/relations, then run `verify`
40
+ only after the code/test semantic check is complete, and `render`.
41
+
42
+ ## Change workflow
43
+
44
+ 1. Define goal, scope, and non-goals.
45
+ 2. State intended behavior.
46
+ 3. Capture affected contracts and invariants.
47
+ 4. Add relevant edge cases, compatibility, migration, and risks.
48
+ 5. Define verification.
49
+ 6. Implement only when requested.
50
+ 7. After implementation, verify the spec against code/tests.
51
+ 8. For a material production-behavior change, run the post-change checkpoint in
52
+ `maintenance.md` using the paths changed by this task. This is required even
53
+ when the spec you started from appears sufficient: newly introduced files may
54
+ reveal previously unknown spec relationships.
55
+ 9. If the project uses Spec Wiki, refresh metadata with `record`, repair durable
56
+ relation changes with `relate`, then establish the verified baseline with
57
+ `verify` only after implementation/test verification and the impact sweep.
58
+
59
+ If the task creates a new primary spec, record it immediately. If it moves a
60
+ primary spec, record/verify the new path before removing the old metadata entry.
61
+
62
+ ## Default template
63
+
64
+ Use only when the repository has no stronger convention. Remove irrelevant
65
+ sections.
66
+
67
+ ```markdown
68
+ # Spec: <name>
69
+
70
+ ## Type
71
+ As-is | Change
72
+
73
+ ## Goal
74
+ ...
75
+
76
+ ## Scope
77
+ ...
78
+
79
+ ## Non-goals
80
+ ...
81
+
82
+ ## Behavior
83
+ ...
84
+
85
+ ## Contracts
86
+ Inputs, outputs, APIs, CLI, UI, events, files, schemas.
87
+
88
+ ## Invariants
89
+ ...
90
+
91
+ ## Edge cases
92
+ ...
93
+
94
+ ## Side effects
95
+ ...
96
+
97
+ ## Related files
98
+ ...
99
+
100
+ ## Verification
101
+ ...
102
+
103
+ ## Risks / unknowns
104
+ ...
105
+
106
+ ## Evidence
107
+ - Confirmed by code:
108
+ - Confirmed by tests:
109
+ - Confirmed by docs:
110
+ - Inferred:
111
+ - Unknown:
112
+ ```
113
+
114
+ ## Report back
115
+
116
+ Summarize the spec path, as-is/change mode, strongest evidence, important
117
+ unknowns/drift, and whether production code was changed.
@@ -0,0 +1,330 @@
1
+ # Spec Wiki state and CLI reference
2
+
3
+ <!-- markdownlint-disable MD013 -->
4
+
5
+ This reference describes the deterministic storage layer. Primary specification
6
+ documents remain the source of truth.
7
+
8
+ ## Files
9
+
10
+ ```text
11
+ .spec-wiki/index.md # compact generated routing index
12
+ .spec-wiki/state.json # semantic metadata + structural/verification baselines
13
+ .spec-wiki/config.jsonc # optional discovery overrides
14
+ ```
15
+
16
+ ## State schema v2
17
+
18
+ Conceptual primary entry:
19
+
20
+ ```json
21
+ {
22
+ "path": "docs/auth.md",
23
+ "title": "Authentication contract",
24
+ "classification": "spec",
25
+ "type": "as-is",
26
+ "lifecycle": "active",
27
+ "confidence": "high",
28
+ "summary": "Authentication session lifecycle and refresh invariants.",
29
+ "topics": ["auth", "sessions"],
30
+ "relations": {
31
+ "code": [
32
+ {"path": "src/auth/session.ts", "source": "explicit"}
33
+ ],
34
+ "specs": [
35
+ {"path": "docs/oauth.md", "source": "inferred", "kind": "related"}
36
+ ]
37
+ },
38
+ "unresolvedReferences": [],
39
+ "indexed": {
40
+ "at": "2026-09-09T00:00:00Z",
41
+ "sourceHash": "sha256:..."
42
+ },
43
+ "verified": {
44
+ "at": "2026-09-09T00:05:00Z",
45
+ "sourceHash": "sha256:...",
46
+ "relationsHash": "sha256:...",
47
+ "codeHashes": {
48
+ "src/auth/session.ts": "sha256:..."
49
+ }
50
+ }
51
+ }
52
+ ```
53
+
54
+ State keys and all stored paths are normalized project-relative POSIX paths.
55
+
56
+ ### Classification
57
+
58
+ - `spec` — primary behavioral/normative specification.
59
+ - `spec-like` — primary-ish knowledge with mixed/ambiguous purpose.
60
+ - `meta-index` — inventory, overview, catalog, TOC, generated index.
61
+ - `design-only` — design/decision material without enough behavioral contract.
62
+ - `guide` — tutorial, runbook, usage/operational documentation.
63
+ - `other` — not useful specification knowledge.
64
+
65
+ Only `spec`/`spec-like` are primary specs. `design-only` may be searched as
66
+ secondary context with `search --include-secondary`.
67
+
68
+ ### Type
69
+
70
+ - `as-is` — describes current behavior.
71
+ - `change` — intended/changed behavior.
72
+ - `mixed` — intentionally contains both.
73
+ - `unknown` — not safely determined.
74
+
75
+ ### Lifecycle
76
+
77
+ Lifecycle is separate from Type:
78
+
79
+ - `active` — current authoritative contract.
80
+ - `proposed` — intended contract that is not yet current.
81
+ - `historical` — useful milestone/history, not current precedence.
82
+ - `superseded` — replaced by a newer primary document.
83
+ - `unknown` — precedence cannot be established safely.
84
+
85
+ For known replacement relationships use:
86
+
87
+ - `kind: related`
88
+ - `kind: supersedes`
89
+ - `kind: superseded-by`
90
+
91
+ ### Indexed vs verified
92
+
93
+ `indexed` is refreshed by `record`. It means the document was classified and
94
+ summarized at that exact source hash.
95
+
96
+ `verified` is written only by `verify`. It means the agent has semantically
97
+ checked the spec against its relevant implementation/tests/evidence and accepted
98
+ the current tracked-input baseline. The baseline also fingerprints the current
99
+ code/spec relation map. Adding or removing a relation therefore invalidates
100
+ freshness until semantic review and `verify` establish a new baseline.
101
+
102
+ Therefore a clean bootstrap produces `unverified` primary specs, not `fresh`.
103
+
104
+ ## Freshness statuses
105
+
106
+ - `fresh` — source and tracked code inputs match an explicit verified baseline.
107
+ - `unverified` — indexed but no semantic-verification baseline exists.
108
+ - `spec-changed` — source differs from indexed/verified baseline.
109
+ - `inputs-changed` — one or more tracked implementation inputs differ/missing.
110
+ - `spec+inputs-changed` — both source and implementation inputs changed.
111
+ - `missing-source` — primary source disappeared/moved.
112
+
113
+ Hash status is structural evidence only; `inputs-changed` requests semantic
114
+ review and must not rewrite behavior automatically.
115
+
116
+ ## Relationship discovery
117
+
118
+ Explicit path/link resolution tries, in order:
119
+
120
+ 1. the source document directory;
121
+ 2. ancestor package roots containing markers such as `package.json`,
122
+ `pyproject.toml`, `Cargo.toml`, `go.mod`, or `Package.swift`;
123
+ 3. repository root.
124
+
125
+ This lets a doc under `external/package/docs/` resolve `src/foo.ts` against the
126
+ package root. Simple `{a,b}` path groups are expanded.
127
+
128
+ If the document explicitly says that paths/references below are relative to a
129
+ backticked existing project directory (for example `external/tool-suite/`), that
130
+ directory is also used as a resolution base. This covers root-level specs that
131
+ document one nested package using package-relative paths.
132
+
133
+ Path-like tokens that still cannot resolve are stored in
134
+ `unresolvedReferences`. They are diagnostic hints, not silently discarded.
135
+
136
+ ## Optional config.jsonc
137
+
138
+ ```jsonc
139
+ {
140
+ "includeExtensions": [".md", ".mdx", ".rst", ".adoc", ".txt"],
141
+ "include": ["docs/**", "architecture/**", "features/**"],
142
+ "exclude": ["legacy/**", "generated-docs/**"],
143
+ "forceSpecs": ["protocol/*.txt"],
144
+ "ignoreSpecs": ["docs/spec-template.md"],
145
+ "minCandidateScore": 3,
146
+ "maxFileBytes": 524288
147
+ }
148
+ ```
149
+
150
+ The scanner excludes its own state plus common dependency/build/cache dirs.
151
+ When Git is available it uses tracked + unignored untracked files; hashing also
152
+ works without Git.
153
+
154
+ ## CLI
155
+
156
+ Global options:
157
+
158
+ ```text
159
+ --root PATH project root; defaults to Git root, then cwd
160
+ --state-dir PATH alternate wiki directory; relative paths are root-relative
161
+ --config PATH alternate config.jsonc/json path
162
+ ```
163
+
164
+ ### discover
165
+
166
+ ```bash
167
+ spec_wiki.py --root . discover --limit 40
168
+ spec_wiki.py --root . discover --all --json
169
+ spec_wiki.py --root . discover --all-unclassified --limit 40
170
+ ```
171
+
172
+ Produces a heuristic shortlist. `roleHint` is not a semantic classification.
173
+ After recording a page, rerun from offset 0 because the shortlist shrinks.
174
+ `--all-unclassified` is a bounded periodic coverage audit: it bypasses candidate
175
+ score for unclassified document-like files while still excluding known
176
+ fixture/skill-resource noise unless forced by config.
177
+
178
+ ### record
179
+
180
+ ```bash
181
+ spec_wiki.py --root . record \
182
+ --path docs/auth.md \
183
+ --classification spec \
184
+ --type as-is \
185
+ --lifecycle active \
186
+ --confidence high \
187
+ --summary "Authentication lifecycle and refresh invariants." \
188
+ --topic auth --topic sessions \
189
+ --code src/auth/session.ts \
190
+ --related-spec docs/oauth.md
191
+ ```
192
+
193
+ `record` updates classification, summary, topics, relationships, unresolved
194
+ references, and the `indexed` source hash. It **does not verify** the entry.
195
+ The first `spec`/`spec-like` record requires explicit `--type` and
196
+ `--lifecycle` (use `unknown` only after semantic inspection cannot decide).
197
+
198
+ Additional spec relationship flags are repeatable:
199
+
200
+ ```text
201
+ --supersedes PATH
202
+ --superseded-by PATH
203
+ ```
204
+
205
+ `--clear-code` and `--clear-related-specs` remove previously inferred relations;
206
+ explicit source links are re-extracted each time.
207
+
208
+ ### verify
209
+
210
+ ```bash
211
+ spec_wiki.py --root . verify --path docs/auth.md
212
+ ```
213
+
214
+ Run only after semantic review. It hashes the current source and every tracked
215
+ code/test input plus the current relation map and establishes the new verified
216
+ baseline. Missing tracked inputs fail rather than being silently accepted.
217
+
218
+ ### relate
219
+
220
+ Use `relate` to repair inferred relations without resupplying the full semantic
221
+ record:
222
+
223
+ ```bash
224
+ spec_wiki.py --root . relate --path docs/auth.md --add-code src/auth/refresh.ts
225
+ spec_wiki.py --root . relate --path docs/auth.md --remove-code src/auth/legacy.ts
226
+ ```
227
+
228
+ It also supports add/remove variants for related specs, `supersedes`, and
229
+ `superseded-by`. Explicit relations extracted from the primary source are not
230
+ removed by this command; correct the source document instead. A real relation
231
+ change makes the previous verified baseline non-fresh through `relationsHash`.
232
+
233
+ ### search
234
+
235
+ ```bash
236
+ spec_wiki.py --root . search "session cancellation retry" --limit 8
237
+ spec_wiki.py --root . search "как восстановить историю" \
238
+ --also "session recovery raw history after compaction" \
239
+ --also "session recovery tools" --json
240
+ spec_wiki.py --root . search "context gateway" --include-secondary --json
241
+ ```
242
+
243
+ Searches state metadata directly: title, topics, summary, spec path, known code
244
+ relations, related-spec relations, and supersession edges. Exact spec/relation
245
+ paths have strong weight. Relation token scoring uses concrete leaf names rather
246
+ than generic directory segments.
247
+
248
+ `--also` is repeatable. The CLI scores each formulation independently, then
249
+ merges them deterministically. The intended caller is the current LLM: preserve
250
+ the original request and, for natural-language intents, add 2–3 genuinely
251
+ different English formulations (canonical contract nouns/synonyms plus implied
252
+ failure/invariant vocabulary) without making another model call. Exact paths and
253
+ symbols usually need no expansion.
254
+
255
+ JSON output includes `confidence`, `catalogFallbackRecommended`,
256
+ `semanticRerankRecommended`, coverage metrics, and per-query match evidence.
257
+ These are routing hints, not semantic proof. The agent still reranks candidates
258
+ from compact metadata. If fallback is recommended, results are empty, or the
259
+ candidate set plainly misses part of the intent, inspect the compact generated
260
+ `index.md` before deciding no relevant spec exists.
261
+
262
+ Active specs rank above proposed/historical/superseded ones. This is the normal
263
+ retrieval path; reading the entire generated index is a semantic fallback.
264
+
265
+ ### status / audit
266
+
267
+ ```bash
268
+ spec_wiki.py --root . status
269
+ spec_wiki.py --root . audit --json
270
+ ```
271
+
272
+ Reports current/proposed primary count, fresh/unverified/review counts,
273
+ unresolved reference count, missing sources, and new/changed candidates.
274
+ `needs review` counts structural drift/missing sources; cleanly indexed but never
275
+ verified specs are reported separately as `unverified`.
276
+
277
+ ### affected
278
+
279
+ ```bash
280
+ spec_wiki.py --root . affected src/auth/session.ts src/storage
281
+ ```
282
+
283
+ Returns current/proposed primary specs whose source or tracked code relations
284
+ overlap supplied paths. Historical/superseded specs are skipped.
285
+
286
+ ### changes / impact
287
+
288
+ ```bash
289
+ spec_wiki.py --root . changes --json
290
+ spec_wiki.py --root . impact src/auth/session.ts src/auth/refresh.ts --json
291
+ spec_wiki.py --root . impact --base HEAD --json
292
+ ```
293
+
294
+ `changes` reports Git worktree changes, untracked files, and renames while
295
+ excluding Spec Wiki's own state directory.
296
+
297
+ `impact` is the deterministic post-change maintenance primitive. Explicit paths
298
+ keep it scoped to the current task; with no paths it uses Git changes against
299
+ `--base`. It returns known affected specs, uncovered changed paths, every changed
300
+ document-like file (even score-0), missing/moved tracked specs, and a
301
+ `semanticSweepRequired` flag. Uncovered paths are search seeds for LLM semantic
302
+ impact review, not proof that a spec is missing.
303
+
304
+ ### render
305
+
306
+ ```bash
307
+ spec_wiki.py --root . render
308
+ ```
309
+
310
+ Generates a compact one-line-per-spec routing index. Historical/superseded specs
311
+ and secondary design references are separate sections. Full summaries remain in
312
+ state and are retrieved through `search`.
313
+
314
+ ### remove
315
+
316
+ ```bash
317
+ spec_wiki.py --root . remove --path docs/old-contract.md
318
+ ```
319
+
320
+ Removes metadata only. For a move, record the new path before removing the old.
321
+
322
+ ### validate
323
+
324
+ ```bash
325
+ spec_wiki.py --root . validate
326
+ ```
327
+
328
+ Checks schema/path/hash/relationship safety. Stale/unverified current specs,
329
+ unresolved path hints, and active as-is specs without implementation relations
330
+ are warnings rather than malformed-state errors.
@@ -0,0 +1,134 @@
1
+ # Maintain an existing Spec Wiki
2
+
3
+ Use for refresh, audit, changed-code impact analysis, missing/moved specs, and
4
+ repair of an existing `.spec-wiki/` knowledge base.
5
+
6
+ ## Routine refresh
7
+
8
+ 1. Run `status`.
9
+ 2. Re-read changed primary specs and reclassify changed non-primary documents
10
+ when `impact` marks them for classification/reclassification.
11
+ 3. For `inputs-changed`, inspect the affected behavior against code/tests before
12
+ updating any spec claim or verified baseline.
13
+ 4. Use the focused workflow in `focused-spec.md` when semantic verification is
14
+ required.
15
+ 5. `record` updated metadata/relations first. This does not clear drift.
16
+ 6. After semantic verification succeeds, run `verify --path <spec>` to establish
17
+ the new source/input baseline.
18
+ 7. Run `render` and `validate`.
19
+
20
+ ## Mandatory post-change checkpoint
21
+
22
+ Run this after any **material production-behavior change** before reporting the
23
+ task complete. Skip it for formatting-only/mechanical edits that cannot affect a
24
+ behavioral contract.
25
+
26
+ 1. Prefer the exact paths changed by the current task and run:
27
+
28
+ ```bash
29
+ spec_wiki.py --root . impact <task-paths...>
30
+ ```
31
+
32
+ If task-scoped paths are unavailable, `impact` with no paths inspects the Git
33
+ working tree against `HEAD`. On an already-dirty worktree this is broader than
34
+ the current task, so do not attribute unrelated changes to the user task.
35
+ 2. Treat every `knownAffected` primary spec as a semantic-review candidate.
36
+ 3. Treat every material `uncoveredPath` as a **mandatory semantic impact sweep**,
37
+ even when `affected` returned nothing. Inspect the changed code/diff, form 2–3
38
+ distinct English retrieval formulations, run hybrid `search --also ...`, and
39
+ semantically rerank the compact candidates. Use the catalog fallback described
40
+ in `query.md` when search recommends it or coverage is incomplete.
41
+ 4. If the sweep reveals a previously unknown durable spec→code dependency, repair
42
+ the relation map with `relate --add-code ...` (or update the source spec's
43
+ Related files and `record` it). Do not add relations merely because paths share
44
+ names.
45
+ 5. If a tracked relation is obsolete or a file moved, remove/replace only the
46
+ inferred edge with `relate --remove-code ...`; explicit source links should be
47
+ corrected in the primary spec itself. Any relation-map change invalidates the
48
+ old verified baseline until semantic verification succeeds again.
49
+ 6. Every changed/new document reported by `impact.changedDocuments` must be
50
+ classified for the current task **regardless of heuristic score**. A score-0
51
+ changed `.txt` may still be a real contract.
52
+ 7. After semantic review, update affected specs only when their behavioral claims
53
+ changed. Then `record` changed metadata/source, `verify` each reviewed current
54
+ spec, `render`, and `validate`.
55
+
56
+ The checkpoint is successful when material changed paths have either a known and
57
+ reviewed spec relationship or a documented semantic decision that no current spec
58
+ is affected. `affected` alone is never sufficient proof of no impact.
59
+
60
+ ## Freshness states
61
+
62
+ - `fresh`: source and tracked inputs match the verified hash baseline.
63
+ - `spec-changed`: primary document changed; review summary/classification.
64
+ - `inputs-changed`: tracked implementation input changed; semantic review needed.
65
+ - `spec+inputs-changed`: both changed.
66
+ - `missing-source`: primary source disappeared or moved.
67
+ - `unverified`: no valid semantic-verification baseline.
68
+
69
+ Never rewrite behavior automatically from `inputs-changed`.
70
+
71
+ Historical/superseded specs remain searchable knowledge but are not treated as
72
+ current review obligations. Use lifecycle and supersession relations to keep old
73
+ milestone contracts from competing with current specs.
74
+
75
+ ## Impact analysis
76
+
77
+ Use `affected <paths...>` after code changes to identify specs with known tracked
78
+ relationships to those paths. It is a conservative hint: absence from the
79
+ result does not prove no spec is affected.
80
+
81
+ Prefer explicit source links. Add inferred implementation relations only after
82
+ inspection; do not guess paths to improve coverage.
83
+
84
+ Review unresolved path hints reported by `status`/`validate`, especially for
85
+ active as-is specs. A current as-is spec with no tracked implementation inputs
86
+ cannot provide useful automatic drift detection.
87
+
88
+ `impact` additionally reports changed paths with **no known** current spec
89
+ relationship. Those paths are where semantic discovery is most important.
90
+
91
+ ## New specs and discovery coverage
92
+
93
+ - A spec created by the current task should be `record`ed immediately; do not wait
94
+ for a later repository scan.
95
+ - `impact` exposes every changed/new document-like file for classification even
96
+ when normal discovery heuristics would rank it below the candidate threshold.
97
+ - Routine `status` still discovers ordinary new/changed high-signal spec
98
+ candidates across the repository.
99
+ - Before releases, after large refactors, or when coverage is in doubt, run a
100
+ **bounded deep coverage audit**:
101
+
102
+ ```bash
103
+ spec_wiki.py --root . discover --all-unclassified --limit 40
104
+ ```
105
+
106
+ This intentionally bypasses the heuristic threshold for unclassified document-
107
+ like files. Page it carefully on large repositories and classify only after
108
+ reading the document itself. This is the safety net for committed low-signal
109
+ specs that are no longer visible in the current Git diff.
110
+
111
+ ## Missing or moved specs
112
+
113
+ - Confirmed deletion: `remove --path <old-path>` removes metadata only.
114
+ - Move: `impact` reports the old tracked source as missing and the new document
115
+ as a classification candidate. Record the new source first, preserve/repair its
116
+ relations and lifecycle, verify it, then remove the old metadata entry.
117
+
118
+ ## Safety
119
+
120
+ - Primary specs remain the source of truth.
121
+ - Do not modify existing project indexes merely to satisfy Spec Wiki.
122
+ - Do not normalize arbitrary specs into a mandatory format.
123
+ - Hash freshness is structural, not semantic correctness.
124
+ - Verified freshness also fingerprints the relation map. Adding/removing tracked
125
+ inputs invalidates the previous baseline even when no source/code bytes changed.
126
+ - Preserve manual classifications unless source/evidence justifies a change.
127
+
128
+ ## Report back
129
+
130
+ Summarize wiki path, primary-spec count, unclassified candidates, specs needing
131
+ review and why, missing/moved sources, and whether primary specs or production
132
+ code were modified.
133
+
134
+ For exact command/config/state details, read `index-schema.md`.
@@ -0,0 +1,74 @@
1
+ # Query existing spec knowledge
2
+
3
+ Use this mode to find relevant specs or answer a question grounded in existing
4
+ specifications without loading the whole corpus.
5
+
6
+ ## If `.spec-wiki/` exists
7
+
8
+ 1. Turn the user's intent into a small retrieval bundle **in the current model**;
9
+ do not make a separate model call. Keep the original query. For ordinary
10
+ natural-language requests add **2–3 genuinely different** concise English
11
+ aliases rather than echoing the same words:
12
+ - behavior → canonical contract nouns/synonyms (`recover` → `recovery`,
13
+ `wrong session update` → `async ownership lifecycle concurrency`);
14
+ - failure/invariant vocabulary implied by the request (`prompt caching` →
15
+ `cache stability`, `cannot delete before provider` → provider-seen/result
16
+ retention);
17
+ - likely component terminology only when the request itself gives enough
18
+ evidence.
19
+ For non-English requests, always include at least one English behavior alias
20
+ and one compact contract-noun alias. Exact symbols or file paths are already
21
+ strong retrieval keys and may be searched without extra aliases. Do not invent
22
+ a feature name merely to make search easier.
23
+ 2. Run one deterministic search with the bundle, for example:
24
+
25
+ ```bash
26
+ spec_wiki.py --root . search "<original>" \
27
+ --also "<behavior alias>" \
28
+ --also "<component/contract alias>" \
29
+ --limit 8 --json
30
+ ```
31
+
32
+ Search uses title/topics/summary/spec path plus known code/spec/supersession
33
+ relations. Exact relation paths receive strong weight.
34
+ 3. Semantically rerank the returned candidates yourself from their compact
35
+ metadata. Numeric score is candidate generation, not the final truth. Prefer
36
+ entries that satisfy the whole intent, not entries matching one repeated
37
+ domain word.
38
+ 4. If `catalogFallbackRecommended` is true, search returns nothing, or the top
39
+ candidates plainly miss an important part of the request, read the compact
40
+ `.spec-wiki/index.md` and select candidates semantically from the catalog.
41
+ **Never conclude that no relevant spec exists from lexical search alone.**
42
+ 5. Prefer `active` entries over `proposed`, `historical`, or `superseded` ones.
43
+ Use `--include-secondary` only when design/decision context is useful.
44
+ 6. Read the selected primary source documents before making detailed claims.
45
+ When uncertain, read a few plausible specs rather than silently dropping one.
46
+ 7. If a selected spec is `unverified`, say that its semantic baseline has not
47
+ been established. If it is `inputs-changed`, `spec-changed`, or otherwise stale,
48
+ warn about freshness and use `focused-spec.md` when semantic verification is
49
+ needed.
50
+
51
+ Do not run `status` before every narrow query: each search result already carries
52
+ its freshness status. Use `status` for broad wiki-health/audit questions.
53
+
54
+ Do not treat `index.md` summaries as primary evidence when the source spec is
55
+ available.
56
+
57
+ ## If no wiki exists
58
+
59
+ For a narrow question, search only for likely relevant specs and answer from
60
+ those sources. Do **not** bootstrap the full wiki unless the user asks for an
61
+ inventory/index or broad spec discovery.
62
+
63
+ ## Existing project indexes
64
+
65
+ An existing README, overview, spec catalog, or TOC may be used as a discovery
66
+ hint, but its summaries are not primary spec knowledge. Follow links to the
67
+ underlying documents and ground claims there.
68
+
69
+ ## Freshness
70
+
71
+ `fresh` means known source/input hashes match an **explicit semantic-verification
72
+ baseline**. Bootstrap/classification alone produces `unverified`, never `fresh`.
73
+
74
+ `inputs-changed` is a review request, not proof of drift.