@clawplays/ospec-cli 0.4.0 → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -60
- package/SKILL.md +3 -0
- package/assets/for-ai/en-US/ai-guide.md +5 -32
- package/assets/for-ai/en-US/execution-protocol.md +5 -7
- package/assets/global-skills/claude/ospec-change/SKILL.md +4 -5
- package/assets/global-skills/codex/ospec-change/SKILL.md +4 -5
- package/assets/global-skills/codex/ospec-change/agents/openai.yaml +1 -1
- package/assets/global-skills/codex/ospec-change/skill.yaml +1 -3
- package/assets/plugins/registry.json +47 -0
- package/assets/project-conventions/en-US/workflow-conventions.md +1 -2
- package/dist/advanced/BatchOperations.d.ts +1 -1
- package/dist/advanced/BatchOperations.js +1 -1
- package/dist/advanced/CachingLayer.d.ts +13 -13
- package/dist/advanced/CachingLayer.js +16 -16
- package/dist/advanced/FeatureUpdater.d.ts +9 -9
- package/dist/advanced/FeatureUpdater.js +14 -14
- package/dist/advanced/PerformanceMonitor.d.ts +10 -10
- package/dist/advanced/PerformanceMonitor.js +11 -11
- package/dist/advanced/StatePersistence.d.ts +11 -11
- package/dist/advanced/StatePersistence.js +15 -15
- package/dist/advanced/index.d.ts +2 -2
- package/dist/advanced/index.js +2 -2
- package/dist/cli.d.ts +1 -1
- package/dist/cli.js +18 -4
- package/dist/commands/ArchiveCommand.d.ts +3 -1
- package/dist/commands/ArchiveCommand.js +84 -6
- package/dist/commands/BaseCommand.d.ts +8 -8
- package/dist/commands/BaseCommand.js +7 -7
- package/dist/commands/BatchCommand.d.ts +1 -1
- package/dist/commands/BatchCommand.js +1 -1
- package/dist/commands/ChangesCommand.js +1 -1
- package/dist/commands/DocsCommand.d.ts +1 -1
- package/dist/commands/DocsCommand.js +1 -1
- package/dist/commands/FinalizeCommand.js +1 -1
- package/dist/commands/IndexCommand.d.ts +1 -1
- package/dist/commands/IndexCommand.js +1 -1
- package/dist/commands/InitCommand.d.ts +1 -1
- package/dist/commands/InitCommand.js +1 -1
- package/dist/commands/LayoutCommand.d.ts +9 -0
- package/dist/commands/LayoutCommand.js +225 -0
- package/dist/commands/NewCommand.d.ts +1 -1
- package/dist/commands/NewCommand.js +59 -20
- package/dist/commands/PluginsCommand.d.ts +29 -3
- package/dist/commands/PluginsCommand.js +1217 -37
- package/dist/commands/ProgressCommand.d.ts +1 -1
- package/dist/commands/ProgressCommand.js +5 -2
- package/dist/commands/QueueCommand.d.ts +1 -1
- package/dist/commands/QueueCommand.js +1 -1
- package/dist/commands/RunCommand.d.ts +1 -1
- package/dist/commands/RunCommand.js +1 -1
- package/dist/commands/SkillCommand.d.ts +1 -1
- package/dist/commands/SkillCommand.js +23 -17
- package/dist/commands/SkillsCommand.d.ts +1 -1
- package/dist/commands/SkillsCommand.js +1 -1
- package/dist/commands/StatusCommand.d.ts +1 -1
- package/dist/commands/StatusCommand.js +8 -4
- package/dist/commands/UpdateCommand.d.ts +7 -1
- package/dist/commands/UpdateCommand.js +262 -27
- package/dist/commands/VerifyCommand.d.ts +2 -1
- package/dist/commands/VerifyCommand.js +80 -3
- package/dist/commands/WorkflowCommand.d.ts +3 -3
- package/dist/commands/WorkflowCommand.js +5 -5
- package/dist/commands/index.d.ts +3 -4
- package/dist/commands/index.js +5 -5
- package/dist/core/constants.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/errors.d.ts +2 -2
- package/dist/core/errors.js +2 -2
- package/dist/core/index.d.ts +2 -2
- package/dist/core/index.js +2 -2
- package/dist/core/types.d.ts +9 -5
- package/dist/core/types.js +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/presets/ProjectPresets.d.ts +1 -1
- package/dist/presets/ProjectPresets.js +1 -1
- package/dist/scaffolds/ProjectScaffoldPresets.d.ts +1 -1
- package/dist/scaffolds/ProjectScaffoldPresets.js +1 -1
- package/dist/services/ConfigManager.d.ts +1 -1
- package/dist/services/ConfigManager.js +271 -3
- package/dist/services/FileService.d.ts +2 -2
- package/dist/services/FileService.js +2 -2
- package/dist/services/IndexBuilder.d.ts +2 -1
- package/dist/services/IndexBuilder.js +24 -6
- package/dist/services/Logger.d.ts +2 -2
- package/dist/services/Logger.js +2 -2
- package/dist/services/PluginRegistryService.d.ts +175 -0
- package/dist/services/PluginRegistryService.js +1006 -0
- package/dist/services/ProjectAssetRegistry.d.ts +1 -1
- package/dist/services/ProjectAssetRegistry.js +1 -1
- package/dist/services/ProjectAssetService.d.ts +7 -4
- package/dist/services/ProjectAssetService.js +29 -22
- package/dist/services/ProjectScaffoldCommandService.d.ts +1 -1
- package/dist/services/ProjectScaffoldCommandService.js +1 -1
- package/dist/services/ProjectScaffoldService.d.ts +1 -1
- package/dist/services/ProjectScaffoldService.js +1 -1
- package/dist/services/ProjectService.d.ts +6 -1
- package/dist/services/ProjectService.js +134 -89
- package/dist/services/QueueService.d.ts +2 -1
- package/dist/services/QueueService.js +19 -4
- package/dist/services/RunService.d.ts +2 -1
- package/dist/services/RunService.js +25 -9
- package/dist/services/SkillParser.d.ts +5 -5
- package/dist/services/SkillParser.js +5 -5
- package/dist/services/StateManager.d.ts +1 -1
- package/dist/services/StateManager.js +1 -1
- package/dist/services/TemplateEngine.d.ts +1 -1
- package/dist/services/TemplateEngine.js +1 -1
- package/dist/services/TemplateGenerator.d.ts +11 -11
- package/dist/services/TemplateGenerator.js +22 -22
- package/dist/services/ValidationService.d.ts +5 -5
- package/dist/services/ValidationService.js +5 -5
- package/dist/services/index.d.ts +2 -2
- package/dist/services/index.js +10 -3
- package/dist/services/templates/ExecutionTemplateBuilder.d.ts +1 -1
- package/dist/services/templates/ExecutionTemplateBuilder.js +1 -1
- package/dist/services/templates/ProjectTemplateBuilder.d.ts +1 -1
- package/dist/services/templates/ProjectTemplateBuilder.js +3 -3
- package/dist/services/templates/TemplateBuilderBase.d.ts +1 -1
- package/dist/services/templates/TemplateBuilderBase.js +1 -1
- package/dist/services/templates/TemplateInputFactory.d.ts +1 -1
- package/dist/services/templates/TemplateInputFactory.js +1 -1
- package/dist/services/templates/templateTypes.d.ts +1 -1
- package/dist/services/templates/templateTypes.js +1 -1
- package/dist/tools/build-index.js +55 -11
- package/dist/utils/DateUtils.d.ts +5 -5
- package/dist/utils/DateUtils.js +5 -5
- package/dist/utils/PathUtils.d.ts +7 -3
- package/dist/utils/PathUtils.js +15 -5
- package/dist/utils/ProjectLayout.d.ts +8 -0
- package/dist/utils/ProjectLayout.js +102 -0
- package/dist/utils/StringUtils.d.ts +7 -7
- package/dist/utils/StringUtils.js +7 -7
- package/dist/utils/helpers.d.ts +1 -1
- package/dist/utils/helpers.js +1 -1
- package/dist/utils/index.d.ts +2 -2
- package/dist/utils/index.js +2 -2
- package/dist/utils/subcommandHelp.d.ts +1 -1
- package/dist/utils/subcommandHelp.js +7 -2
- package/dist/workflow/ArchiveGate.d.ts +1 -1
- package/dist/workflow/ArchiveGate.js +1 -1
- package/dist/workflow/ConfigurableWorkflow.d.ts +15 -15
- package/dist/workflow/ConfigurableWorkflow.js +16 -16
- package/dist/workflow/HookSystem.d.ts +8 -8
- package/dist/workflow/HookSystem.js +9 -9
- package/dist/workflow/IndexRegenerator.d.ts +8 -8
- package/dist/workflow/IndexRegenerator.js +12 -12
- package/dist/workflow/PluginWorkflowComposer.d.ts +1 -1
- package/dist/workflow/PluginWorkflowComposer.js +38 -50
- package/dist/workflow/SkillUpdateEngine.d.ts +1 -1
- package/dist/workflow/SkillUpdateEngine.js +1 -1
- package/dist/workflow/VerificationSystem.d.ts +1 -1
- package/dist/workflow/VerificationSystem.js +1 -1
- package/dist/workflow/WorkflowEngine.d.ts +1 -1
- package/dist/workflow/WorkflowEngine.js +1 -1
- package/dist/workflow/index.d.ts +2 -2
- package/dist/workflow/index.js +2 -2
- package/package.json +4 -13
- package/skill.yaml +0 -1
- package/dist/adapters/codex-stitch-adapter.js +0 -420
- package/dist/adapters/gemini-stitch-adapter.js +0 -408
- package/dist/adapters/playwright-checkpoint-adapter.js +0 -2205
- package/dist/cli/commands/config.d.ts +0 -4
- package/dist/cli/commands/config.js +0 -5
- package/dist/cli/commands/feature.d.ts +0 -4
- package/dist/cli/commands/feature.js +0 -5
- package/dist/cli/commands/index.d.ts +0 -4
- package/dist/cli/commands/index.js +0 -5
- package/dist/cli/commands/project.d.ts +0 -4
- package/dist/cli/commands/project.js +0 -5
- package/dist/cli/commands/validate.d.ts +0 -4
- package/dist/cli/commands/validate.js +0 -5
- package/dist/cli/index.d.ts +0 -4
- package/dist/cli/index.js +0 -5
- package/dist/services/FeatureManager.d.ts +0 -4
- package/dist/services/FeatureManager.js +0 -5
- package/dist/services/Validator.d.ts +0 -4
- package/dist/services/Validator.js +0 -5
- package/dist/utils/logger.d.ts +0 -4
- package/dist/utils/logger.js +0 -5
- package/dist/utils/path.d.ts +0 -4
- package/dist/utils/path.js +0 -5
package/README.md
CHANGED
|
@@ -23,13 +23,13 @@
|
|
|
23
23
|
|
|
24
24
|
The official OSpec CLI package is `@clawplays/ospec-cli`, and the official command is `ospec`. OSpec supports spec-driven development (SDD) and document-driven development for AI coding agents and CLI workflows.
|
|
25
25
|
|
|
26
|
-
OSpec.ai is the official project site. `OSpec`, `ospec`, `ospec.ai`, `ospec ai`, `ospecai`, and `ospec-ai` all point to the same official project and CLI.
|
|
27
|
-
|
|
28
26
|
<p align="center">
|
|
29
27
|
<a href="docs/prompt-guide.md">Prompt Guide</a> |
|
|
30
28
|
<a href="docs/usage.md">Usage</a> |
|
|
31
29
|
<a href="docs/project-overview.md">Overview</a> |
|
|
32
30
|
<a href="docs/installation.md">Installation</a> |
|
|
31
|
+
<a href="docs/external-plugins.md">External Plugins</a> |
|
|
32
|
+
<a href="docs/plugin-release.md">Plugin Release</a> |
|
|
33
33
|
<a href="https://github.com/clawplays/ospec/issues">Issues</a>
|
|
34
34
|
</p>
|
|
35
35
|
|
|
@@ -91,8 +91,10 @@ CLI notes:
|
|
|
91
91
|
- `--architecture`: short architecture description
|
|
92
92
|
- `--document-language`: generated doc language, choose from `en-US`, `zh-CN`, `ja-JP`, or `ar`
|
|
93
93
|
- AI-first language resolution order: explicit language request in the conversation -> current conversation language -> persisted project language in `.skillrc`
|
|
94
|
-
- CLI language resolution order: explicit `--document-language` -> persisted project language in `.skillrc` -> existing project docs / `for-ai/*` / asset manifest -> fallback `en-US`
|
|
94
|
+
- CLI language resolution order: explicit `--document-language` -> persisted project language in `.skillrc` -> existing project docs / managed `for-ai/*` guidance / asset manifest -> fallback `en-US`
|
|
95
95
|
- OSpec persists the chosen project document language in `.skillrc` and reuses it for `for-ai` guidance, `ospec new`, and `ospec update`
|
|
96
|
+
- new projects initialized by `ospec init` default to the nested layout: root `.skillrc` and `README.md`, with OSpec-managed files under `.ospec/`
|
|
97
|
+
- CLI commands still accept shorthand like `changes/active/<change-name>`, but the physical path in nested projects is `.ospec/changes/active/<change-name>`
|
|
96
98
|
- if you pass these values, OSpec uses them directly when generating project docs
|
|
97
99
|
- if you do not pass them, OSpec reuses existing docs when possible and otherwise creates placeholder docs first
|
|
98
100
|
|
|
@@ -154,7 +156,8 @@ Archive notes:
|
|
|
154
156
|
- run your project-specific deploy, test, and QA flow first
|
|
155
157
|
- use `ospec verify` to confirm the active change is ready
|
|
156
158
|
- use `ospec finalize` to rebuild indexes and archive the accepted change
|
|
157
|
-
- new projects archive under
|
|
159
|
+
- new nested projects archive under `.ospec/changes/archived/YYYY-MM/YYYY-MM-DD/<change-name>`; CLI shorthand under `changes/archived/...` still works
|
|
160
|
+
- existing flat archives are reorganized by `ospec update`
|
|
158
161
|
|
|
159
162
|
</details>
|
|
160
163
|
|
|
@@ -167,6 +170,11 @@ ospec update
|
|
|
167
170
|
```
|
|
168
171
|
|
|
169
172
|
`ospec update` also migrates legacy root-level `build-index-auto.cjs` / `build-index-auto.js` tooling into `.ospec/tools/build-index-auto.cjs` and refreshes OSpec-managed hook entrypoints to use the new location.
|
|
173
|
+
It also repairs older OSpec projects that still have an OSpec footprint but are missing newer core runtime directories, refreshes managed skills and archive layout metadata, and syncs project assets for already-enabled plugins.
|
|
174
|
+
When an already-enabled plugin has a newer compatible npm package version available, `ospec update` upgrades that global plugin package automatically and prints the version transition.
|
|
175
|
+
It does not upgrade the CLI itself, and it does not enable plugins or migrate active / queued changes automatically.
|
|
176
|
+
It also does not switch a classic project layout to nested automatically.
|
|
177
|
+
If you want to convert an older classic project to the new layout, run `ospec layout migrate --to nested` explicitly.
|
|
170
178
|
|
|
171
179
|
## How The OSpec Workflow Works
|
|
172
180
|
|
|
@@ -181,10 +189,11 @@ ospec update
|
|
|
181
189
|
│ 2. INIT TO CHANGE-READY │
|
|
182
190
|
│ ospec init │
|
|
183
191
|
│ - .skillrc │
|
|
192
|
+
│ - README.md │
|
|
184
193
|
│ - .ospec/ │
|
|
185
|
-
│ - changes/active + changes/archived
|
|
186
|
-
│ -
|
|
187
|
-
│ - docs/project/* baseline knowledge docs
|
|
194
|
+
│ - .ospec/changes/active + .ospec/changes/archived │
|
|
195
|
+
│ - .ospec/SKILL.md + .ospec/SKILL.index.json + .ospec/for-ai│
|
|
196
|
+
│ - .ospec/docs/project/* baseline knowledge docs │
|
|
188
197
|
│ - reuse docs or fall back to placeholders │
|
|
189
198
|
└─────────────────────────────────────────────────────────────────┘
|
|
190
199
|
│
|
|
@@ -214,7 +223,7 @@ ospec update
|
|
|
214
223
|
|
|
215
224
|
| Concept | What It Means |
|
|
216
225
|
|---------|---------------|
|
|
217
|
-
| **Protocol Shell** | The minimum collaboration skeleton: `.skillrc`, `.ospec
|
|
226
|
+
| **Protocol Shell** | The minimum collaboration skeleton: root `.skillrc` and `README.md`, plus managed OSpec files under `.ospec/` for change state, SKILL docs, index state, `for-ai/` guidance, and project docs. |
|
|
218
227
|
| **Project Knowledge Layer** | Explicit project context such as `docs/project/*`, layered skill files, and index state that AI can read consistently. |
|
|
219
228
|
| **Active Change** | A dedicated execution container for one requirement, usually with `proposal.md`, `tasks.md`, `state.json`, `verification.md`, and `review.md`. |
|
|
220
229
|
|
|
@@ -226,70 +235,40 @@ ospec update
|
|
|
226
235
|
- **Docs maintenance**: `ospec docs generate` refreshes or repairs project knowledge docs when you need it later.
|
|
227
236
|
- **Tracked requirement execution**: each change can keep proposal, tasks, state, verification, and review files aligned.
|
|
228
237
|
- **Queue helpers**: `queue` and `run` support explicit multi-change execution when one active change is not enough.
|
|
229
|
-
- **Plugin workflow gates**:
|
|
238
|
+
- **Plugin workflow gates**: plugin commands support Stitch design review and Checkpoint automation through npm-installed official plugins.
|
|
230
239
|
- **Skill management**: install and inspect OSpec skills for Codex and Claude Code.
|
|
231
240
|
- **Standard closeout**: `finalize` verifies, rebuilds indexes, and archives the change before manual Git commit.
|
|
232
241
|
|
|
233
|
-
## Plugin
|
|
234
|
-
|
|
235
|
-
OSpec includes two optional plugins that extend the document-driven workflow with UI review and flow validation.
|
|
236
|
-
|
|
237
|
-
### Stitch
|
|
242
|
+
## Plugin Installation
|
|
238
243
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
AI conversation:
|
|
244
|
+
OSpec supports plugins for UI review and runtime validation.
|
|
245
|
+
Keep the public flow simple:
|
|
242
246
|
|
|
243
247
|
```text
|
|
244
|
-
|
|
248
|
+
$ospec open Stitch for this project.
|
|
249
|
+
$ospec open Checkpoint for this project.
|
|
245
250
|
```
|
|
246
251
|
|
|
247
|
-
|
|
252
|
+
In AI / `$ospec` flows, requests like "open Stitch" or "open Checkpoint" should be handled as: check whether the plugin is already installed globally, install only when missing, then enable it in the current project.
|
|
248
253
|
|
|
249
|
-
|
|
250
|
-
$ospec enable the Stitch plugin and connect using Codex/Gemini.
|
|
251
|
-
```
|
|
252
|
-
|
|
253
|
-
<details>
|
|
254
|
-
<summary>Command line</summary>
|
|
254
|
+
Command line fallback:
|
|
255
255
|
|
|
256
256
|
```bash
|
|
257
|
+
ospec plugins list
|
|
258
|
+
ospec plugins install stitch
|
|
257
259
|
ospec plugins enable stitch .
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
</details>
|
|
261
|
-
|
|
262
|
-
### Checkpoint
|
|
263
|
-
|
|
264
|
-
Use Checkpoint for app flow validation and automated checks, especially for submission flows, critical paths, and pre-acceptance runtime verification.
|
|
265
|
-
|
|
266
|
-
AI conversation:
|
|
267
|
-
|
|
268
|
-
```text
|
|
269
|
-
OSpec, enable the Checkpoint plugin.
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
Claude / Codex skill mode:
|
|
273
|
-
|
|
274
|
-
```text
|
|
275
|
-
$ospec enable the Checkpoint plugin.
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
<details>
|
|
279
|
-
<summary>Command line</summary>
|
|
280
|
-
|
|
281
|
-
```bash
|
|
260
|
+
ospec plugins install checkpoint
|
|
282
261
|
ospec plugins enable checkpoint . --base-url http://127.0.0.1:3000
|
|
283
262
|
```
|
|
284
263
|
|
|
285
|
-
|
|
264
|
+
Official npm plugin packages:
|
|
286
265
|
|
|
287
|
-
-
|
|
288
|
-
-
|
|
289
|
-
- If a user asks an AI assistant to enable Checkpoint, that install step must complete before the plugin should be considered successfully enabled
|
|
290
|
-
- Disabling Checkpoint only turns off the plugin configuration; it does not uninstall those project dependencies
|
|
266
|
+
- `@clawplays/ospec-plugin-stitch`
|
|
267
|
+
- `@clawplays/ospec-plugin-checkpoint`
|
|
291
268
|
|
|
292
|
-
|
|
269
|
+
After a plugin is enabled, its detailed setup docs are synced into `.ospec/plugins/<plugin>/docs/`.
|
|
270
|
+
|
|
271
|
+
Maintainers can find plugin publishing and automation details in `docs/plugin-release.md`.
|
|
293
272
|
|
|
294
273
|
## Documentation
|
|
295
274
|
|
|
@@ -300,11 +279,8 @@ Notes:
|
|
|
300
279
|
- [Project Overview](docs/project-overview.md)
|
|
301
280
|
- [Installation](docs/installation.md)
|
|
302
281
|
- [Skills Installation](docs/skills-installation.md)
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
- [Stitch Plugin Spec](docs/stitch-plugin-spec.md)
|
|
307
|
-
- [Checkpoint Plugin Spec](docs/checkpoint-plugin-spec.md)
|
|
282
|
+
- [External Plugins](docs/external-plugins.md)
|
|
283
|
+
- [Plugin Release](docs/plugin-release.md)
|
|
308
284
|
|
|
309
285
|
## Repository Structure
|
|
310
286
|
|
package/SKILL.md
CHANGED
|
@@ -198,6 +198,9 @@ ospec run status [path]
|
|
|
198
198
|
ospec run step [path]
|
|
199
199
|
ospec run resume [path]
|
|
200
200
|
ospec run stop [path]
|
|
201
|
+
ospec plugins available
|
|
202
|
+
ospec plugins info <plugin>
|
|
203
|
+
ospec plugins install <plugin>
|
|
201
204
|
ospec plugins status [path]
|
|
202
205
|
ospec plugins approve stitch [changes/active/<change>]
|
|
203
206
|
ospec plugins reject stitch [changes/active/<change>]
|
|
@@ -18,7 +18,7 @@ This document is the project-adopted AI guide copied from the OSpec mother spec.
|
|
|
18
18
|
4. Read the relevant `SKILL.md` files
|
|
19
19
|
5. Read the current change execution files
|
|
20
20
|
6. If Stitch is enabled and the current change activates `stitch_design_review`, inspect `artifacts/stitch/approval.json` first
|
|
21
|
-
7. If you need to handle Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement, read the repo-local localized plugin
|
|
21
|
+
7. If you need to handle Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement, read the repo-local localized plugin docs under `.ospec/plugins/<plugin>/docs/` first; if they are missing, install or enable the plugin to sync its docs before changing config
|
|
22
22
|
|
|
23
23
|
## Required Behavior
|
|
24
24
|
|
|
@@ -41,7 +41,7 @@ This document is the project-adopted AI guide copied from the OSpec mother spec.
|
|
|
41
41
|
- If the project uses a custom runner and `token_env` is configured, confirm the matching environment variable is set before running
|
|
42
42
|
- If the runner, Gemini CLI, Codex CLI, stitch MCP, or auth readiness is unclear, run `ospec plugins doctor stitch <project-path>` first
|
|
43
43
|
- If `plugins doctor stitch` reports non-PASS for the selected provider checks, prompt the user to install the required CLI and complete the stitch MCP / API token setup in the matching user config
|
|
44
|
-
- For Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup, read
|
|
44
|
+
- For Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup, read `.ospec/plugins/stitch/docs/` first and follow the plugin's documented config shape instead of inventing a `command` / `args` / `env` or stdio-proxy workaround just to satisfy doctor
|
|
45
45
|
- If the built-in `codex` provider succeeds on read-only calls but `create_project`, `generate_screen`, or `edit_screens` stalls locally, first verify the run actually uses `codex exec --dangerously-bypass-approvals-and-sandbox`
|
|
46
46
|
- If the project explicitly overrides `.skillrc.plugins.stitch.runner` and Codex still performs Stitch writes, the custom runner / wrapper must also pass `--dangerously-bypass-approvals-and-sandbox`
|
|
47
47
|
- Sync `SKILL.md` after meaningful code changes
|
|
@@ -54,37 +54,10 @@ This document is the project-adopted AI guide copied from the OSpec mother spec.
|
|
|
54
54
|
- Workflow conventions: `docs/project/workflow-conventions.md`
|
|
55
55
|
- Development guide: `docs/project/development-guide.md`
|
|
56
56
|
|
|
57
|
-
## Stitch Provider
|
|
57
|
+
## Stitch Provider Docs
|
|
58
58
|
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
- `gemini`: edit `%USERPROFILE%/.gemini/settings.json` and use `mcpServers.stitch.httpUrl` plus `headers.X-Goog-Api-Key`.
|
|
62
|
-
|
|
63
|
-
```json
|
|
64
|
-
{
|
|
65
|
-
"mcpServers": {
|
|
66
|
-
"stitch": {
|
|
67
|
-
"httpUrl": "https://stitch.googleapis.com/mcp",
|
|
68
|
-
"headers": {
|
|
69
|
-
"X-Goog-Api-Key": "your-stitch-api-key"
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
```
|
|
75
|
-
|
|
76
|
-
- `codex`: edit `%USERPROFILE%/.codex/config.toml` and use HTTP transport, the fixed Stitch MCP URL, and the `X-Goog-Api-Key` header.
|
|
77
|
-
- The built-in `codex` adapter should launch Stitch write operations through `codex exec --dangerously-bypass-approvals-and-sandbox`; if a custom runner replaces it, that runner must provide the same write-bypass behavior.
|
|
78
|
-
|
|
79
|
-
```toml
|
|
80
|
-
[mcp_servers.stitch]
|
|
81
|
-
type = "http"
|
|
82
|
-
url = "https://stitch.googleapis.com/mcp"
|
|
83
|
-
headers = { X-Goog-Api-Key = "your-stitch-api-key" }
|
|
84
|
-
|
|
85
|
-
[mcp_servers.stitch.http_headers]
|
|
86
|
-
X-Goog-Api-Key = "your-stitch-api-key"
|
|
87
|
-
```
|
|
59
|
+
- Provider, MCP, auth, and runner details live in `.ospec/plugins/stitch/docs/` after the Stitch plugin is installed and enabled for the project.
|
|
60
|
+
- If those docs are missing, install or enable Stitch first so the plugin can sync its localized docs into the repository before changing config.
|
|
88
61
|
|
|
89
62
|
## Stitch Canonical Layout
|
|
90
63
|
|
|
@@ -15,7 +15,7 @@ tags: [ai, protocol, ospec]
|
|
|
15
15
|
5. `docs/project/workflow-conventions.md`
|
|
16
16
|
6. The current change files: `proposal.md / tasks.md / state.json / verification.md`
|
|
17
17
|
7. If `stitch_design_review` exists, read `artifacts/stitch/approval.json`
|
|
18
|
-
8. If Stitch or Checkpoint provider, MCP, auth, install, or enable config must be changed, read the repo-local localized plugin
|
|
18
|
+
8. If Stitch or Checkpoint provider, MCP, auth, install, or enable config must be changed, read the repo-local localized plugin docs under `.ospec/plugins/<plugin>/docs/` first; if they are missing, install or enable the plugin to sync its docs before changing config
|
|
19
19
|
|
|
20
20
|
## Mandatory Rules
|
|
21
21
|
|
|
@@ -36,7 +36,7 @@ tags: [ai, protocol, ospec]
|
|
|
36
36
|
- Before running Stitch, assume the built-in `stitch` plugin uses the configured provider by default; only treat `.skillrc.plugins.stitch.runner` as authoritative when the project explicitly overrides it
|
|
37
37
|
- If the project uses a custom runner and `token_env` is configured, confirm the matching environment variable is set
|
|
38
38
|
- If the local Stitch bridge, Gemini CLI, Codex CLI, stitch MCP, or auth readiness is unclear, run `ospec plugins doctor stitch <project-path>` first
|
|
39
|
-
- If `plugins doctor stitch` reveals provider, MCP, or auth issues, return to
|
|
39
|
+
- If `plugins doctor stitch` reveals provider, MCP, or auth issues, return to `.ospec/plugins/stitch/docs/` first; do not invent an alternate `command` / `args` / `env` or stdio-proxy config outside the plugin docs
|
|
40
40
|
- If the built-in `codex` provider can complete read-only calls but `create_project`, `generate_screen`, or `edit_screens` stalls locally, first verify the run actually uses `codex exec --dangerously-bypass-approvals-and-sandbox`
|
|
41
41
|
- If the project explicitly overrides `.skillrc.plugins.stitch.runner` and still uses Codex for Stitch writes, the custom runner / wrapper must also pass `--dangerously-bypass-approvals-and-sandbox`
|
|
42
42
|
- If `stitch_design_review` is active and `approval.json.status != approved`, do not treat the change as ready for continued implementation, completion, or archive
|
|
@@ -47,12 +47,10 @@ tags: [ai, protocol, ospec]
|
|
|
47
47
|
|
|
48
48
|
If the project rules differ from the mother spec, the project-adopted rules take precedence.
|
|
49
49
|
|
|
50
|
-
## Stitch Provider
|
|
50
|
+
## Stitch Provider Docs
|
|
51
51
|
|
|
52
|
-
-
|
|
53
|
-
- If
|
|
54
|
-
- If the project does not contain that spec and the built-in `codex` provider is used, the baseline config is `%USERPROFILE%/.codex/config.toml` with `[mcp_servers.stitch]`, `type = "http"`, `url = "https://stitch.googleapis.com/mcp"`, and `X-Goog-Api-Key` in `headers` or `[mcp_servers.stitch.http_headers]`.
|
|
55
|
-
- The built-in `codex` provider should launch Stitch write operations with `--dangerously-bypass-approvals-and-sandbox`; if a custom runner replaces it, that runner must carry the same write-bypass behavior explicitly.
|
|
52
|
+
- Provider / MCP / auth config must follow the localized Stitch plugin docs under `.ospec/plugins/stitch/docs/`.
|
|
53
|
+
- If those docs are missing, install or enable Stitch first so the plugin can sync its localized docs into the repository before changing config.
|
|
56
54
|
|
|
57
55
|
## Stitch Theme Variant Prompt Contract
|
|
58
56
|
|
|
@@ -26,7 +26,9 @@ This skill is the single entry for the full change lifecycle inside an initializ
|
|
|
26
26
|
2. `SKILL.index.json`
|
|
27
27
|
3. `for-ai/ai-guide.md`
|
|
28
28
|
4. `for-ai/execution-protocol.md`
|
|
29
|
-
5. If Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement is involved, read the
|
|
29
|
+
5. If Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement is involved, read the localized plugin docs under `.ospec/plugins/<plugin>/docs/` first. Before any install step, check `ospec plugins info <plugin>` or `ospec plugins installed`. If the plugin is already installed globally, reuse it and enable it in the current project instead of reinstalling it.
|
|
30
|
+
6. Treat `ospec update [path]` as project-scoped. It repairs the current project and only upgrades plugins that are enabled in that project.
|
|
31
|
+
7. Do not run `ospec plugins update --all` unless the user explicitly asks to update every installed plugin on the machine.
|
|
30
32
|
6. If the user explicitly asks for queue behavior, inspect `changes/queued/` before creating new queue items.
|
|
31
33
|
7. `changes/active/<change>/proposal.md`
|
|
32
34
|
8. `changes/active/<change>/tasks.md`
|
|
@@ -57,10 +59,7 @@ When `.skillrc.plugins.stitch.enabled = true` and `.skillrc.plugins.stitch.capab
|
|
|
57
59
|
- treat the built-in `stitch` plugin with the configured provider adapter as the default path unless `.skillrc.plugins.stitch.runner` is explicitly overridden
|
|
58
60
|
- if a custom runner is configured and `token_env` is set but missing, stop and request configuration first
|
|
59
61
|
- if runner readiness, provider CLI, stitch MCP, or auth readiness is unclear, use `ospec plugins doctor stitch <project-path>` before `ospec plugins run stitch <change-path>`
|
|
60
|
-
- if Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup is involved, read
|
|
61
|
-
- if the repo-local Stitch spec is missing, use these built-in baselines instead of guessing:
|
|
62
|
-
- `gemini`: `%USERPROFILE%/.gemini/settings.json` -> `mcpServers.stitch.httpUrl = "https://stitch.googleapis.com/mcp"` and `headers.X-Goog-Api-Key`
|
|
63
|
-
- `codex`: `%USERPROFILE%/.codex/config.toml` -> `[mcp_servers.stitch]`, `type = "http"`, `url = "https://stitch.googleapis.com/mcp"`, and `X-Goog-Api-Key` in `headers` or `[mcp_servers.stitch.http_headers]`
|
|
62
|
+
- if Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup is involved, read `.ospec/plugins/stitch/docs/` first and follow the plugin's documented config snippets instead of inventing `command` / `args` / `env` or stdio-proxy settings
|
|
64
63
|
- use `ospec plugins approve stitch <change-path>` or `ospec plugins reject stitch <change-path>` to record the review result
|
|
65
64
|
|
|
66
65
|
## Required Logic
|
|
@@ -27,7 +27,9 @@ This skill is the single entry for the full change lifecycle inside an initializ
|
|
|
27
27
|
2. `SKILL.index.json`
|
|
28
28
|
3. `for-ai/ai-guide.md`
|
|
29
29
|
4. `for-ai/execution-protocol.md`
|
|
30
|
-
5. If Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement is involved, read the
|
|
30
|
+
5. If Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement is involved, read the localized plugin docs under `.ospec/plugins/<plugin>/docs/` first. Before any install step, check `ospec plugins info <plugin>` or `ospec plugins installed`. If the plugin is already installed globally, reuse it and enable it in the current project instead of reinstalling it.
|
|
31
|
+
6. Treat `ospec update [path]` as project-scoped. It repairs the current project and only upgrades plugins that are enabled in that project.
|
|
32
|
+
7. Do not run `ospec plugins update --all` unless the user explicitly asks to update every installed plugin on the machine.
|
|
31
33
|
6. If the user explicitly asks for queue behavior, inspect `changes/queued/` before creating new queue items.
|
|
32
34
|
7. `changes/active/<change>/proposal.md`
|
|
33
35
|
8. `changes/active/<change>/tasks.md`
|
|
@@ -58,10 +60,7 @@ When `.skillrc.plugins.stitch.enabled = true` and `.skillrc.plugins.stitch.capab
|
|
|
58
60
|
- treat the built-in `stitch` plugin with the configured provider adapter as the default path unless `.skillrc.plugins.stitch.runner` is explicitly overridden
|
|
59
61
|
- if a custom runner is configured and `token_env` is set but missing, stop and request configuration first
|
|
60
62
|
- if runner readiness, provider CLI, stitch MCP, or auth readiness is unclear, use `ospec plugins doctor stitch <project-path>` before `ospec plugins run stitch <change-path>`
|
|
61
|
-
- if Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup is involved, read
|
|
62
|
-
- if the repo-local Stitch spec is missing, use these built-in baselines instead of guessing:
|
|
63
|
-
- `gemini`: `%USERPROFILE%/.gemini/settings.json` -> `mcpServers.stitch.httpUrl = "https://stitch.googleapis.com/mcp"` and `headers.X-Goog-Api-Key`
|
|
64
|
-
- `codex`: `%USERPROFILE%/.codex/config.toml` -> `[mcp_servers.stitch]`, `type = "http"`, `url = "https://stitch.googleapis.com/mcp"`, and `X-Goog-Api-Key` in `headers` or `[mcp_servers.stitch.http_headers]`
|
|
63
|
+
- if Stitch installation, provider switching, doctor remediation, MCP setup, or auth setup is involved, read `.ospec/plugins/stitch/docs/` first and follow the plugin's documented config snippets instead of inventing `command` / `args` / `env` or stdio-proxy settings
|
|
65
64
|
- use `ospec plugins approve stitch <change-path>` or `ospec plugins reject stitch <change-path>` to record the review result
|
|
66
65
|
|
|
67
66
|
## Required Logic
|
|
@@ -4,4 +4,4 @@ interface:
|
|
|
4
4
|
|
|
5
5
|
short_description: "Create or advance a change"
|
|
6
6
|
|
|
7
|
-
default_prompt: "Use $ospec-change to create or advance a OSpec change. Read .skillrc, SKILL.index.json, and the current change files first. Default to one active change and do not enter queue mode unless the user explicitly asks to split work into multiple changes, create a queue, or execute a queue. When queue behavior is explicitly requested, derive an ordered kebab-case list of change names, use ospec queue add to create queued changes, and use ospec run manual-safe only when the user explicitly asks to run the queue. Keep protocol execution inside changes/active/<change> and do not confuse bootstrap with change creation. If Stitch is enabled and stitch_design_review is active, inspect artifacts/stitch/approval.json.
|
|
7
|
+
default_prompt: "Use $ospec-change to create or advance a OSpec change. Read .skillrc, SKILL.index.json, and the current change files first. Default to one active change and do not enter queue mode unless the user explicitly asks to split work into multiple changes, create a queue, or execute a queue. When queue behavior is explicitly requested, derive an ordered kebab-case list of change names, use ospec queue add to create queued changes, and use ospec run manual-safe only when the user explicitly asks to run the queue. Keep protocol execution inside changes/active/<change> and do not confuse bootstrap with change creation. If Stitch is enabled and stitch_design_review is active, inspect artifacts/stitch/approval.json. Before any plugin install step, check `ospec plugins info <plugin>` or `ospec plugins installed`. If the plugin is already installed globally, reuse it and only enable it in the current project. Only run `ospec plugins install <plugin>` when the plugin is not installed yet or the user explicitly asks to reinstall or upgrade it. Treat `ospec update [path]` as project-scoped: it repairs the current project and only upgrades plugins that are enabled in that project. Do not run `ospec plugins update --all` unless the user explicitly asks to update every installed plugin on the machine. If plugin installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement is involved, read `.ospec/plugins/<plugin>/docs/` first; if those docs are missing, install or enable the plugin to sync them before changing config. If preview_url or submitted_at is empty, run ospec plugins run stitch <change-path> before asking for review."
|
|
@@ -4,8 +4,6 @@ title: OSpec Change
|
|
|
4
4
|
|
|
5
5
|
description: Create or advance an active change inside a OSpec project while respecting workflow files and optional-step activation.
|
|
6
6
|
|
|
7
|
-
version: 5.1.0
|
|
8
|
-
|
|
9
7
|
author: OSpec Team
|
|
10
8
|
|
|
11
9
|
license: MIT
|
|
@@ -16,4 +14,4 @@ interface:
|
|
|
16
14
|
|
|
17
15
|
short_description: "Create or advance a change"
|
|
18
16
|
|
|
19
|
-
default_prompt: "Use $ospec-change to create or advance a OSpec change. Read .skillrc, SKILL.index.json, and the current change files first. Default to one active change and do not enter queue mode unless the user explicitly asks to split work into multiple changes, create a queue, or execute a queue. When queue behavior is explicitly requested, derive an ordered kebab-case list of change names, use ospec queue add to create queued changes, and use ospec run manual-safe only when the user explicitly asks to run the queue. Keep protocol execution inside changes/active/<change> and do not confuse bootstrap with change creation. If Stitch is enabled and stitch_design_review is active, inspect artifacts/stitch/approval.json.
|
|
17
|
+
default_prompt: "Use $ospec-change to create or advance a OSpec change. Read .skillrc, SKILL.index.json, and the current change files first. Default to one active change and do not enter queue mode unless the user explicitly asks to split work into multiple changes, create a queue, or execute a queue. When queue behavior is explicitly requested, derive an ordered kebab-case list of change names, use ospec queue add to create queued changes, and use ospec run manual-safe only when the user explicitly asks to run the queue. Keep protocol execution inside changes/active/<change> and do not confuse bootstrap with change creation. If Stitch is enabled and stitch_design_review is active, inspect artifacts/stitch/approval.json. Before any plugin install step, check `ospec plugins info <plugin>` or `ospec plugins installed`. If the plugin is already installed globally, reuse it and only enable it in the current project. Only run `ospec plugins install <plugin>` when the plugin is not installed yet or the user explicitly asks to reinstall or upgrade it. Treat `ospec update [path]` as project-scoped: it repairs the current project and only upgrades plugins that are enabled in that project. Do not run `ospec plugins update --all` unless the user explicitly asks to update every installed plugin on the machine. If plugin installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement is involved, read `.ospec/plugins/<plugin>/docs/` first; if those docs are missing, install or enable the plugin to sync them before changing config. Reuse .skillrc.plugins.stitch.project.project_id when it already exists; if it is empty, treat the first successful Stitch run as the canonical project. If preview_url or submitted_at is empty, run ospec plugins run stitch <change-path> before asking for review."
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 1,
|
|
3
|
+
"plugins": [
|
|
4
|
+
{
|
|
5
|
+
"id": "checkpoint",
|
|
6
|
+
"packageName": "@clawplays/ospec-plugin-checkpoint",
|
|
7
|
+
"installRange": ">=1.0.0 <2.0.0",
|
|
8
|
+
"displayName": "Checkpoint",
|
|
9
|
+
"official": true,
|
|
10
|
+
"description": "Runtime review and flow validation for OSpec projects.",
|
|
11
|
+
"kinds": [
|
|
12
|
+
"runtime",
|
|
13
|
+
"skill",
|
|
14
|
+
"knowledge"
|
|
15
|
+
],
|
|
16
|
+
"docs": {
|
|
17
|
+
"locales": {
|
|
18
|
+
"en-US": "plugins/checkpoint/docs/plugin.md",
|
|
19
|
+
"zh-CN": "plugins/checkpoint/docs/plugin.zh-CN.md",
|
|
20
|
+
"ja-JP": "plugins/checkpoint/docs/plugin.ja.md",
|
|
21
|
+
"ar": "plugins/checkpoint/docs/plugin.ar.md"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
"id": "stitch",
|
|
27
|
+
"packageName": "@clawplays/ospec-plugin-stitch",
|
|
28
|
+
"installRange": ">=1.0.0 <2.0.0",
|
|
29
|
+
"displayName": "Stitch",
|
|
30
|
+
"official": true,
|
|
31
|
+
"description": "Page design review and preview collaboration for OSpec projects.",
|
|
32
|
+
"kinds": [
|
|
33
|
+
"runtime",
|
|
34
|
+
"skill",
|
|
35
|
+
"knowledge"
|
|
36
|
+
],
|
|
37
|
+
"docs": {
|
|
38
|
+
"locales": {
|
|
39
|
+
"en-US": "plugins/stitch/docs/plugin.md",
|
|
40
|
+
"zh-CN": "plugins/stitch/docs/plugin.zh-CN.md",
|
|
41
|
+
"ja-JP": "plugins/stitch/docs/plugin.ja.md",
|
|
42
|
+
"ar": "plugins/stitch/docs/plugin.ar.md"
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -50,8 +50,7 @@ This document fixes the OSpec execution flow inside the project so requirements
|
|
|
50
50
|
- `ospec plugins run stitch <change-path>` uses the configured Stitch provider adapter by default; if the project explicitly overrides `.skillrc.plugins.stitch.runner`, use the custom Stitch bridge / wrapper instead
|
|
51
51
|
- For custom runners, use `token_env` when extra tokens are required; for the built-in Gemini adapter, auth is typically configured under `%USERPROFILE%/.gemini/settings.json` in `mcpServers.stitch`
|
|
52
52
|
- Use `ospec plugins doctor stitch <project-path>` to validate the runner, provider CLI, stitch MCP, and auth-hint readiness
|
|
53
|
-
- For Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement, read the
|
|
54
|
-
- If the repo does not contain a Stitch spec, use the built-in baselines instead: `gemini` edits `%USERPROFILE%/.gemini/settings.json` with `mcpServers.stitch.httpUrl` and `headers.X-Goog-Api-Key`; `codex` edits `%USERPROFILE%/.codex/config.toml` with `[mcp_servers.stitch]`, `type = "http"`, `url = "https://stitch.googleapis.com/mcp"`, and `X-Goog-Api-Key`
|
|
53
|
+
- For Stitch or Checkpoint installation, provider switching, doctor remediation, MCP setup, auth setup, or plugin enablement, read the localized plugin docs under `.ospec/plugins/<plugin>/docs/` first; if they are missing, install or enable the plugin to sync its docs before changing config
|
|
55
54
|
- If the built-in `codex` provider succeeds on read-only calls but local write operations never reach `mcp_tool_call`, first verify the run actually uses `codex exec --dangerously-bypass-approvals-and-sandbox`
|
|
56
55
|
- If the project overrides a custom Codex runner / wrapper, that custom execution path must also pass `--dangerously-bypass-approvals-and-sandbox`
|
|
57
56
|
- When `approval.json.status` is not `approved`, do not claim the change has passed design review or is ready to archive
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
2
|
+
* Caching layer.
|
|
3
|
+
* Optimizes performance and reduces disk access.
|
|
4
4
|
*/
|
|
5
5
|
export interface CacheEntry<T> {
|
|
6
6
|
key: string;
|
|
@@ -15,31 +15,31 @@ export declare class CachingLayer<T = any> {
|
|
|
15
15
|
private cleanupInterval?;
|
|
16
16
|
constructor(maxSize?: number);
|
|
17
17
|
/**
|
|
18
|
-
*
|
|
18
|
+
* Set a cache value.
|
|
19
19
|
*/
|
|
20
20
|
set(key: string, value: T, ttl?: number): void;
|
|
21
21
|
/**
|
|
22
|
-
*
|
|
22
|
+
* Get a cache value.
|
|
23
23
|
*/
|
|
24
24
|
get(key: string): T | null;
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Check whether a key exists.
|
|
27
27
|
*/
|
|
28
28
|
has(key: string): boolean;
|
|
29
29
|
/**
|
|
30
|
-
*
|
|
30
|
+
* Delete a cache entry.
|
|
31
31
|
*/
|
|
32
32
|
delete(key: string): boolean;
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* Clear the cache.
|
|
35
35
|
*/
|
|
36
36
|
clear(): void;
|
|
37
37
|
/**
|
|
38
|
-
*
|
|
38
|
+
* Get cache size.
|
|
39
39
|
*/
|
|
40
40
|
size(): number;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Get cache statistics.
|
|
43
43
|
*/
|
|
44
44
|
getStats(): {
|
|
45
45
|
hits: number;
|
|
@@ -50,16 +50,16 @@ export declare class CachingLayer<T = any> {
|
|
|
50
50
|
maxSize: number;
|
|
51
51
|
};
|
|
52
52
|
/**
|
|
53
|
-
*
|
|
53
|
+
* Start cleaning expired entries.
|
|
54
54
|
*/
|
|
55
55
|
private startCleanup;
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Stop cleanup.
|
|
58
58
|
*/
|
|
59
59
|
stopCleanup(): void;
|
|
60
60
|
/**
|
|
61
|
-
*
|
|
61
|
+
* Dispose the cache.
|
|
62
62
|
*/
|
|
63
63
|
destroy(): void;
|
|
64
64
|
}
|
|
65
|
-
export declare const cachingLayer: CachingLayer<any>;
|
|
65
|
+
export declare const cachingLayer: CachingLayer<any>;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Caching layer.
|
|
4
|
+
* Optimizes performance and reduces disk access.
|
|
5
5
|
*/
|
|
6
6
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
7
|
exports.cachingLayer = exports.CachingLayer = void 0;
|
|
@@ -18,10 +18,10 @@ class CachingLayer {
|
|
|
18
18
|
this.startCleanup();
|
|
19
19
|
}
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
21
|
+
* Set a cache value.
|
|
22
22
|
*/
|
|
23
23
|
set(key, value, ttl) {
|
|
24
|
-
//
|
|
24
|
+
// Remove the oldest entry when the cache exceeds the maximum size.
|
|
25
25
|
if (this.cache.size >= this.maxSize) {
|
|
26
26
|
const oldestKey = Array.from(this.cache.entries()).sort((a, b) => a[1].timestamp - b[1].timestamp)[0]?.[0];
|
|
27
27
|
if (oldestKey) {
|
|
@@ -38,7 +38,7 @@ class CachingLayer {
|
|
|
38
38
|
this.cache.set(key, entry);
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
41
|
+
* Get a cache value.
|
|
42
42
|
*/
|
|
43
43
|
get(key) {
|
|
44
44
|
const entry = this.cache.get(key);
|
|
@@ -46,7 +46,7 @@ class CachingLayer {
|
|
|
46
46
|
this.stats.misses++;
|
|
47
47
|
return null;
|
|
48
48
|
}
|
|
49
|
-
//
|
|
49
|
+
// Check whether the entry has expired.
|
|
50
50
|
if (entry.ttl && Date.now() - entry.timestamp > entry.ttl) {
|
|
51
51
|
this.cache.delete(key);
|
|
52
52
|
this.stats.misses++;
|
|
@@ -56,31 +56,31 @@ class CachingLayer {
|
|
|
56
56
|
return entry.value;
|
|
57
57
|
}
|
|
58
58
|
/**
|
|
59
|
-
*
|
|
59
|
+
* Check whether a key exists.
|
|
60
60
|
*/
|
|
61
61
|
has(key) {
|
|
62
62
|
return this.get(key) !== null;
|
|
63
63
|
}
|
|
64
64
|
/**
|
|
65
|
-
*
|
|
65
|
+
* Delete a cache entry.
|
|
66
66
|
*/
|
|
67
67
|
delete(key) {
|
|
68
68
|
return this.cache.delete(key);
|
|
69
69
|
}
|
|
70
70
|
/**
|
|
71
|
-
*
|
|
71
|
+
* Clear the cache.
|
|
72
72
|
*/
|
|
73
73
|
clear() {
|
|
74
74
|
this.cache.clear();
|
|
75
75
|
}
|
|
76
76
|
/**
|
|
77
|
-
*
|
|
77
|
+
* Get cache size.
|
|
78
78
|
*/
|
|
79
79
|
size() {
|
|
80
80
|
return this.cache.size;
|
|
81
81
|
}
|
|
82
82
|
/**
|
|
83
|
-
*
|
|
83
|
+
* Get cache statistics.
|
|
84
84
|
*/
|
|
85
85
|
getStats() {
|
|
86
86
|
const total = this.stats.hits + this.stats.misses;
|
|
@@ -95,7 +95,7 @@ class CachingLayer {
|
|
|
95
95
|
};
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
|
-
*
|
|
98
|
+
* Start cleaning expired entries.
|
|
99
99
|
*/
|
|
100
100
|
startCleanup() {
|
|
101
101
|
this.cleanupInterval = setInterval(() => {
|
|
@@ -110,12 +110,12 @@ class CachingLayer {
|
|
|
110
110
|
if (removed > 0) {
|
|
111
111
|
this.stats.evictions += removed;
|
|
112
112
|
}
|
|
113
|
-
}, 60000); //
|
|
113
|
+
}, 60000); // Check once per minute.
|
|
114
114
|
// Do not keep unrelated CLI commands alive just because the cache module was imported.
|
|
115
115
|
this.cleanupInterval.unref?.();
|
|
116
116
|
}
|
|
117
117
|
/**
|
|
118
|
-
*
|
|
118
|
+
* Stop cleanup.
|
|
119
119
|
*/
|
|
120
120
|
stopCleanup() {
|
|
121
121
|
if (this.cleanupInterval) {
|
|
@@ -124,7 +124,7 @@ class CachingLayer {
|
|
|
124
124
|
}
|
|
125
125
|
}
|
|
126
126
|
/**
|
|
127
|
-
*
|
|
127
|
+
* Dispose the cache.
|
|
128
128
|
*/
|
|
129
129
|
destroy() {
|
|
130
130
|
this.stopCleanup();
|
|
@@ -132,4 +132,4 @@ class CachingLayer {
|
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
134
|
exports.CachingLayer = CachingLayer;
|
|
135
|
-
exports.cachingLayer = new CachingLayer();
|
|
135
|
+
exports.cachingLayer = new CachingLayer();
|