agent-rulebook 0.1.7 → 0.2.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 +63 -140
- package/dist/commands/home.d.ts +2 -0
- package/dist/commands/home.js +59 -0
- package/dist/commands/home.js.map +1 -0
- package/dist/commands/index.js +11 -10
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/init.js +3 -6
- package/dist/commands/init.js.map +1 -1
- package/dist/commands/output.d.ts +0 -5
- package/dist/commands/output.js +0 -47
- package/dist/commands/output.js.map +1 -1
- package/dist/commands/project.d.ts +2 -0
- package/dist/commands/project.js +33 -0
- package/dist/commands/project.js.map +1 -0
- package/dist/commands/resolution.d.ts +2 -0
- package/dist/commands/resolution.js +32 -0
- package/dist/commands/resolution.js.map +1 -0
- package/dist/commands/sync.d.ts +6 -3
- package/dist/commands/sync.js +130 -177
- package/dist/commands/sync.js.map +1 -1
- package/dist/core/attempt-outcome.d.ts +21 -0
- package/dist/core/attempt-outcome.js +61 -0
- package/dist/core/attempt-outcome.js.map +1 -0
- package/dist/core/change-policy.d.ts +7 -0
- package/dist/core/change-policy.js +14 -0
- package/dist/core/change-policy.js.map +1 -0
- package/dist/core/index.d.ts +34 -33
- package/dist/core/index.js +18 -14
- package/dist/core/index.js.map +1 -1
- package/dist/core/outcome-schema.d.ts +55 -0
- package/dist/core/outcome-schema.js +44 -0
- package/dist/core/outcome-schema.js.map +1 -0
- package/dist/core/problem-fingerprint.d.ts +4 -0
- package/dist/core/problem-fingerprint.js +37 -0
- package/dist/core/problem-fingerprint.js.map +1 -0
- package/dist/core/problem-schema.d.ts +34 -0
- package/dist/core/problem-schema.js +37 -0
- package/dist/core/problem-schema.js.map +1 -0
- package/dist/core/project-environment-detector.d.ts +2 -2
- package/dist/core/project-environment-detector.js +8 -52
- package/dist/core/project-environment-detector.js.map +1 -1
- package/dist/core/project-file-scan.d.ts +17 -0
- package/dist/core/project-file-scan.js +73 -0
- package/dist/core/project-file-scan.js.map +1 -0
- package/dist/core/project-registry.d.ts +8 -0
- package/dist/core/project-registry.js +38 -0
- package/dist/core/project-registry.js.map +1 -0
- package/dist/core/repository-identity.d.ts +7 -0
- package/dist/core/repository-identity.js +27 -0
- package/dist/core/repository-identity.js.map +1 -0
- package/dist/core/resolution-applicability.d.ts +20 -0
- package/dist/core/resolution-applicability.js +38 -0
- package/dist/core/resolution-applicability.js.map +1 -0
- package/dist/core/resolution-parser.d.ts +20 -0
- package/dist/core/resolution-parser.js +47 -0
- package/dist/core/resolution-parser.js.map +1 -0
- package/dist/core/resolution-ranker.d.ts +34 -0
- package/dist/core/resolution-ranker.js +40 -0
- package/dist/core/resolution-ranker.js.map +1 -0
- package/dist/core/resolution-relation.d.ts +14 -0
- package/dist/core/resolution-relation.js +29 -0
- package/dist/core/resolution-relation.js.map +1 -0
- package/dist/core/resolution-schema.d.ts +109 -0
- package/dist/core/resolution-schema.js +29 -0
- package/dist/core/resolution-schema.js.map +1 -0
- package/dist/core/resolution-search-types.d.ts +37 -0
- package/dist/core/resolution-search-types.js +2 -0
- package/dist/core/resolution-search-types.js.map +1 -0
- package/dist/core/resolution-semantic-checksum.d.ts +12 -0
- package/dist/core/resolution-semantic-checksum.js +24 -0
- package/dist/core/resolution-semantic-checksum.js.map +1 -0
- package/dist/core/resolution-writer.d.ts +7 -0
- package/dist/core/resolution-writer.js +33 -0
- package/dist/core/resolution-writer.js.map +1 -0
- package/dist/core/solution-schema.d.ts +42 -0
- package/dist/core/solution-schema.js +28 -0
- package/dist/core/solution-schema.js.map +1 -0
- package/dist/core/source-evidence-schema.d.ts +26 -0
- package/dist/core/source-evidence-schema.js +29 -0
- package/dist/core/source-evidence-schema.js.map +1 -0
- package/dist/core/source-evidence.d.ts +14 -0
- package/dist/core/source-evidence.js +69 -0
- package/dist/core/source-evidence.js.map +1 -0
- package/dist/core/stack-detector.d.ts +2 -2
- package/dist/core/stack-detector.js +11 -63
- package/dist/core/stack-detector.js.map +1 -1
- package/dist/index.d.ts +3 -4
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +3 -3
- package/dist/mcp/index.js +2 -2
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/resolution-change.d.ts +19 -0
- package/dist/mcp/resolution-change.js +136 -0
- package/dist/mcp/resolution-change.js.map +1 -0
- package/dist/mcp/resolutions-commit-change-tool.d.ts +5 -0
- package/dist/mcp/resolutions-commit-change-tool.js +21 -0
- package/dist/mcp/resolutions-commit-change-tool.js.map +1 -0
- package/dist/mcp/resolutions-find-tool.d.ts +5 -0
- package/dist/mcp/resolutions-find-tool.js +75 -0
- package/dist/mcp/resolutions-find-tool.js.map +1 -0
- package/dist/mcp/resolutions-get-source-tool.d.ts +5 -0
- package/dist/mcp/resolutions-get-source-tool.js +30 -0
- package/dist/mcp/resolutions-get-source-tool.js.map +1 -0
- package/dist/mcp/resolutions-get-tool.d.ts +5 -0
- package/dist/mcp/resolutions-get-tool.js +27 -0
- package/dist/mcp/resolutions-get-tool.js.map +1 -0
- package/dist/mcp/resolutions-list-facets-tool.d.ts +4 -0
- package/dist/mcp/resolutions-list-facets-tool.js +18 -0
- package/dist/mcp/resolutions-list-facets-tool.js.map +1 -0
- package/dist/mcp/resolutions-prepare-change-tool.d.ts +5 -0
- package/dist/mcp/resolutions-prepare-change-tool.js +7 -0
- package/dist/mcp/resolutions-prepare-change-tool.js.map +1 -0
- package/dist/mcp/resolutions-report-attempt-tool.d.ts +5 -0
- package/dist/mcp/resolutions-report-attempt-tool.js +87 -0
- package/dist/mcp/resolutions-report-attempt-tool.js.map +1 -0
- package/dist/mcp/schemas.d.ts +265 -197
- package/dist/mcp/schemas.js +28 -93
- package/dist/mcp/schemas.js.map +1 -1
- package/dist/mcp/tool-output.d.ts +0 -34
- package/dist/mcp/tool-output.js +2 -71
- package/dist/mcp/tool-output.js.map +1 -1
- package/dist/mcp/tools.d.ts +973 -204
- package/dist/mcp/tools.js +47 -101
- package/dist/mcp/tools.js.map +1 -1
- package/dist/program.js +7 -9
- package/dist/program.js.map +1 -1
- package/dist/storage/index.d.ts +10 -15
- package/dist/storage/index.js +8 -8
- package/dist/storage/index.js.map +1 -1
- package/dist/storage/project-code-index-source.d.ts +2 -0
- package/dist/storage/project-code-index-source.js +23 -0
- package/dist/storage/project-code-index-source.js.map +1 -0
- package/dist/storage/resolution-candidate-service.d.ts +6 -0
- package/dist/storage/resolution-candidate-service.js +94 -0
- package/dist/storage/resolution-candidate-service.js.map +1 -0
- package/dist/storage/resolution-change-transaction.d.ts +11 -0
- package/dist/storage/resolution-change-transaction.js +56 -0
- package/dist/storage/resolution-change-transaction.js.map +1 -0
- package/dist/storage/resolution-home.d.ts +21 -0
- package/dist/storage/resolution-home.js +62 -0
- package/dist/storage/resolution-home.js.map +1 -0
- package/dist/storage/resolution-index-check.d.ts +28 -0
- package/dist/storage/resolution-index-check.js +30 -0
- package/dist/storage/resolution-index-check.js.map +1 -0
- package/dist/storage/resolution-indexer.d.ts +19 -0
- package/dist/storage/resolution-indexer.js +158 -0
- package/dist/storage/resolution-indexer.js.map +1 -0
- package/dist/storage/resolution-migrations.d.ts +3 -0
- package/dist/storage/resolution-migrations.js +39 -0
- package/dist/storage/resolution-migrations.js.map +1 -0
- package/package.json +5 -3
- package/dist/commands/add.d.ts +0 -2
- package/dist/commands/add.js +0 -134
- package/dist/commands/add.js.map +0 -1
- package/dist/commands/migrate.d.ts +0 -2
- package/dist/commands/migrate.js +0 -73
- package/dist/commands/migrate.js.map +0 -1
- package/dist/commands/rule.d.ts +0 -23
- package/dist/commands/rule.js +0 -158
- package/dist/commands/rule.js.map +0 -1
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -57
- package/dist/commands/search.js.map +0 -1
- package/dist/core/capture-policy.d.ts +0 -6
- package/dist/core/capture-policy.js +0 -5
- package/dist/core/capture-policy.js.map +0 -1
- package/dist/core/compatibility-matcher.d.ts +0 -17
- package/dist/core/compatibility-matcher.js +0 -146
- package/dist/core/compatibility-matcher.js.map +0 -1
- package/dist/core/dedup.d.ts +0 -22
- package/dist/core/dedup.js +0 -54
- package/dist/core/dedup.js.map +0 -1
- package/dist/core/error-signature.d.ts +0 -15
- package/dist/core/error-signature.js +0 -59
- package/dist/core/error-signature.js.map +0 -1
- package/dist/core/facets.d.ts +0 -9
- package/dist/core/facets.js +0 -46
- package/dist/core/facets.js.map +0 -1
- package/dist/core/lesson-importer.d.ts +0 -22
- package/dist/core/lesson-importer.js +0 -94
- package/dist/core/lesson-importer.js.map +0 -1
- package/dist/core/ranker.d.ts +0 -3
- package/dist/core/ranker.js +0 -83
- package/dist/core/ranker.js.map +0 -1
- package/dist/core/rule-compatibility.d.ts +0 -66
- package/dist/core/rule-compatibility.js +0 -53
- package/dist/core/rule-compatibility.js.map +0 -1
- package/dist/core/rule-parser.d.ts +0 -25
- package/dist/core/rule-parser.js +0 -81
- package/dist/core/rule-parser.js.map +0 -1
- package/dist/core/rule-schema.d.ts +0 -283
- package/dist/core/rule-schema.js +0 -213
- package/dist/core/rule-schema.js.map +0 -1
- package/dist/core/rule-writer.d.ts +0 -35
- package/dist/core/rule-writer.js +0 -63
- package/dist/core/rule-writer.js.map +0 -1
- package/dist/core/search-types.d.ts +0 -57
- package/dist/core/search-types.js +0 -2
- package/dist/core/search-types.js.map +0 -1
- package/dist/core/semantic-checksum.d.ts +0 -6
- package/dist/core/semantic-checksum.js +0 -34
- package/dist/core/semantic-checksum.js.map +0 -1
- package/dist/core/slug.d.ts +0 -13
- package/dist/core/slug.js +0 -42
- package/dist/core/slug.js.map +0 -1
- package/dist/mcp/lesson-capture.d.ts +0 -30
- package/dist/mcp/lesson-capture.js +0 -148
- package/dist/mcp/lesson-capture.js.map +0 -1
- package/dist/mcp/rules-add-lesson-tool.d.ts +0 -4
- package/dist/mcp/rules-add-lesson-tool.js +0 -73
- package/dist/mcp/rules-add-lesson-tool.js.map +0 -1
- package/dist/mcp/rules-dedup-lesson-tool.d.ts +0 -4
- package/dist/mcp/rules-dedup-lesson-tool.js +0 -69
- package/dist/mcp/rules-dedup-lesson-tool.js.map +0 -1
- package/dist/mcp/rules-list-facets-tool.d.ts +0 -3
- package/dist/mcp/rules-list-facets-tool.js +0 -31
- package/dist/mcp/rules-list-facets-tool.js.map +0 -1
- package/dist/mcp/rules-prepare-lesson-tool.d.ts +0 -4
- package/dist/mcp/rules-prepare-lesson-tool.js +0 -7
- package/dist/mcp/rules-prepare-lesson-tool.js.map +0 -1
- package/dist/mcp/rules-search-error-tool.d.ts +0 -4
- package/dist/mcp/rules-search-error-tool.js +0 -103
- package/dist/mcp/rules-search-error-tool.js.map +0 -1
- package/dist/mcp/rules-search-for-project-tool.d.ts +0 -4
- package/dist/mcp/rules-search-for-project-tool.js +0 -105
- package/dist/mcp/rules-search-for-project-tool.js.map +0 -1
- package/dist/mcp/rules-search-tool.d.ts +0 -7
- package/dist/mcp/rules-search-tool.js +0 -65
- package/dist/mcp/rules-search-tool.js.map +0 -1
- package/dist/migration/adapters/fenced-lessons.d.ts +0 -2
- package/dist/migration/adapters/fenced-lessons.js +0 -55
- package/dist/migration/adapters/fenced-lessons.js.map +0 -1
- package/dist/migration/adapters/global-rules.d.ts +0 -2
- package/dist/migration/adapters/global-rules.js +0 -72
- package/dist/migration/adapters/global-rules.js.map +0 -1
- package/dist/migration/adapters/index.d.ts +0 -2
- package/dist/migration/adapters/index.js +0 -13
- package/dist/migration/adapters/index.js.map +0 -1
- package/dist/migration/adapters/markdown-lessons.d.ts +0 -2
- package/dist/migration/adapters/markdown-lessons.js +0 -36
- package/dist/migration/adapters/markdown-lessons.js.map +0 -1
- package/dist/migration/adapters/structured-lessons.d.ts +0 -2
- package/dist/migration/adapters/structured-lessons.js +0 -8
- package/dist/migration/adapters/structured-lessons.js.map +0 -1
- package/dist/migration/adapters/structured-shared.d.ts +0 -3
- package/dist/migration/adapters/structured-shared.js +0 -97
- package/dist/migration/adapters/structured-shared.js.map +0 -1
- package/dist/migration/applier.d.ts +0 -32
- package/dist/migration/applier.js +0 -559
- package/dist/migration/applier.js.map +0 -1
- package/dist/migration/index.d.ts +0 -11
- package/dist/migration/index.js +0 -7
- package/dist/migration/index.js.map +0 -1
- package/dist/migration/manifest.d.ts +0 -263
- package/dist/migration/manifest.js +0 -91
- package/dist/migration/manifest.js.map +0 -1
- package/dist/migration/migration-report.d.ts +0 -151
- package/dist/migration/migration-report.js +0 -85
- package/dist/migration/migration-report.js.map +0 -1
- package/dist/migration/scanner.d.ts +0 -2
- package/dist/migration/scanner.js +0 -312
- package/dist/migration/scanner.js.map +0 -1
- package/dist/migration/source-adapter.d.ts +0 -37
- package/dist/migration/source-adapter.js +0 -2
- package/dist/migration/source-adapter.js.map +0 -1
- package/dist/migration/verifier.d.ts +0 -5
- package/dist/migration/verifier.js +0 -218
- package/dist/migration/verifier.js.map +0 -1
- package/dist/storage/index-check.d.ts +0 -21
- package/dist/storage/index-check.js +0 -136
- package/dist/storage/index-check.js.map +0 -1
- package/dist/storage/indexer.d.ts +0 -19
- package/dist/storage/indexer.js +0 -367
- package/dist/storage/indexer.js.map +0 -1
- package/dist/storage/migrations.d.ts +0 -3
- package/dist/storage/migrations.js +0 -126
- package/dist/storage/migrations.js.map +0 -1
- package/dist/storage/rule-discovery.d.ts +0 -4
- package/dist/storage/rule-discovery.js +0 -34
- package/dist/storage/rule-discovery.js.map +0 -1
- package/dist/storage/rule-store.d.ts +0 -10
- package/dist/storage/rule-store.js +0 -12
- package/dist/storage/rule-store.js.map +0 -1
- package/dist/storage/rulebook-home.d.ts +0 -21
- package/dist/storage/rulebook-home.js +0 -78
- package/dist/storage/rulebook-home.js.map +0 -1
- package/dist/storage/search-service.d.ts +0 -17
- package/dist/storage/search-service.js +0 -275
- package/dist/storage/search-service.js.map +0 -1
package/README.md
CHANGED
|
@@ -1,190 +1,113 @@
|
|
|
1
1
|
# Agent Rulebook
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Agent Rulebook is a local-first Resolution Memory for coding agents. It stores observed problems, immutable solution revisions, context-scoped outcomes, and exact source-evidence locators as portable YAML. A derived SQLite index provides retrieval; machine-local project paths never enter canonical data.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Install and initialize
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
7
|
+
```bash
|
|
8
|
+
npm install -g agent-rulebook
|
|
9
|
+
npx -y agent-rulebook@0.2.1 --help
|
|
10
|
+
npx -y agent-rulebook@0.2.1 mcp
|
|
11
|
+
agent-rulebook init
|
|
12
|
+
agent-rulebook index rebuild
|
|
13
|
+
```
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
package in `~/.agent-rulebook` by default. Reinstalling the package or clearing
|
|
16
|
-
the npm cache must not remove that data.
|
|
15
|
+
`agent-rulebook@0.2.1` is an immutable package version. Registry tags such as `latest` are mutable and are not asserted by this artifact. This source revision describes a local release candidate until registry acceptance is recorded.
|
|
17
16
|
|
|
18
|
-
|
|
17
|
+
The home defaults to `~/.agent-rulebook` and can be overridden with `AGENT_RULEBOOK_HOME`. Portable Git data is limited to `config.yaml`, `problems/`, `solutions/`, and `outcomes/`. `projects.local.yaml`, `index/`, and `logs/` stay local.
|
|
19
18
|
|
|
20
|
-
|
|
21
|
-
a global install:
|
|
19
|
+
For an explicitly approved clean break from a legacy rules home, preview the exact deletion allowlist first. Execution requires an exact resolved home, the confirmation phrase, a Git worktree, and `remote.origin.agentRulebookPrivacy=private`:
|
|
22
20
|
|
|
23
21
|
```bash
|
|
24
|
-
|
|
25
|
-
|
|
22
|
+
agent-rulebook home reset --dry-run --json
|
|
23
|
+
agent-rulebook home reset --execute \
|
|
24
|
+
--expected-home /absolute/path/to/.agent-rulebook \
|
|
25
|
+
--confirm 'RESET LEGACY RULEBOOK' --json
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
`
|
|
29
|
-
candidate rollout targets and must not be used until registry publication and
|
|
30
|
-
exact-version readback succeed. Registry tags such as `latest` are
|
|
31
|
-
mutable and are not asserted by this artifact.
|
|
32
|
-
|
|
33
|
-
The `0.1.7` candidate permits automatic lesson capture only when recurrence risk
|
|
34
|
-
is HIGH and at least one of debugging cost or token cost is HIGH, alongside the
|
|
35
|
-
existing deduplication, redaction, scope, compatibility, and verified-fix gates.
|
|
36
|
-
This broadens accepted criteria combinations without changing schema v2 fields
|
|
37
|
-
or rewriting existing rules. Exact-version pinning remains the recommended
|
|
38
|
-
production configuration; Windows x64 remains unsupported and deferred.
|
|
39
|
-
|
|
40
|
-
## Documentation
|
|
41
|
-
|
|
42
|
-
- [Codex adapter setup](docs/adapters/codex.md)
|
|
28
|
+
Reset removes only legacy `rules/` and the derived `index/`, then establishes the v3 bootstrap files and directories. It preserves `.git`, its remote/history, `projects.local.yaml`, and logs.
|
|
43
29
|
|
|
44
|
-
##
|
|
30
|
+
## MCP tools
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
to `rules/**/*.yaml`, `.gitignore`, and a safe `config.yaml` or
|
|
48
|
-
`config.example.yaml`. SQLite/WAL/SHM files, locks, logs, reports, and temporary
|
|
49
|
-
files must remain untracked. Setup documentation stays in this product repository,
|
|
50
|
-
not in the private data remote. If any local artifact or other non-allowlisted
|
|
51
|
-
file is tracked, `sync push` fails with a remediation path.
|
|
32
|
+
The stdio server exposes exactly seven client-neutral tools:
|
|
52
33
|
|
|
53
|
-
|
|
34
|
+
- `resolutions.find`: search at the first unexpected problem using observations, hypotheses, and environment.
|
|
35
|
+
- `resolutions.get`: inspect one candidate's applicability, actions, safety, and verification.
|
|
36
|
+
- `resolutions.get_source`: retrieve one registered source locator at its recorded revision and content hash.
|
|
37
|
+
- `resolutions.list_facets`: inspect indexed environment facets.
|
|
38
|
+
- `resolutions.report_attempt`: append a verified, context-scoped attempt outcome.
|
|
39
|
+
- `resolutions.prepare_change`: classify and validate a verified canonical change without writing.
|
|
40
|
+
- `resolutions.commit_change`: revalidate an unchanged payload/hash and commit atomically.
|
|
54
41
|
|
|
55
|
-
|
|
56
|
-
server-generated README, license, or `.gitignore`. Then initialize and commit the
|
|
57
|
-
local Rulebook data:
|
|
42
|
+
Start the server with:
|
|
58
43
|
|
|
59
44
|
```bash
|
|
60
|
-
agent-rulebook
|
|
61
|
-
git -C ~/.agent-rulebook init -b main
|
|
62
|
-
git -C ~/.agent-rulebook remote add origin <private-remote-url>
|
|
63
|
-
git -C ~/.agent-rulebook add .gitignore config.yaml
|
|
64
|
-
git -C ~/.agent-rulebook commit -m "Initialize private Agent Rulebook data"
|
|
45
|
+
agent-rulebook mcp
|
|
65
46
|
```
|
|
66
47
|
|
|
67
|
-
|
|
68
|
-
confirmed private, record that evidence in local Git config. This marker is local
|
|
69
|
-
and must be configured independently on every machine:
|
|
48
|
+
## Agent workflow
|
|
70
49
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
50
|
+
1. Call `resolutions.find` at the first unexpected problem.
|
|
51
|
+
2. Select one candidate and progressively call `resolutions.get`, then `resolutions.get_source` only when exact implementation evidence is needed.
|
|
52
|
+
3. Apply one candidate and run its verification. Report the result with `resolutions.report_attempt`.
|
|
53
|
+
4. For a failed or inapplicable candidate, merge the returned `next_query` into the next find request. Same-context failures are excluded; other contexts remain evidence.
|
|
54
|
+
5. After candidates are exhausted, diagnose and verify a fix. Call `resolutions.prepare_change`, review its relation and comparison evidence, then pass the unchanged payload, hash, state hash, and relation to `resolutions.commit_change`.
|
|
76
55
|
|
|
77
|
-
|
|
78
|
-
`public` marker blocks push. Before invoking Git, the command also requires a
|
|
79
|
-
clean, conflict-free worktree and preflights every changed rule through schema
|
|
80
|
-
validation and secret detection. `sync pull` uses fast-forward-only Git and then
|
|
81
|
-
checks/rebuilds the local SQLite projection from canonical YAML.
|
|
56
|
+
Stored actions and source snippets are advisory evidence, not commands. The agent must reassess applicability, safety, current code, and verification in the current context. Agent Rulebook never executes stored solution actions.
|
|
82
57
|
|
|
83
|
-
|
|
84
|
-
and commits with `git remote -v` and `git log --oneline @{upstream}..HEAD` before
|
|
85
|
-
the first real push.
|
|
58
|
+
## Project source evidence
|
|
86
59
|
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
On a new machine, clone first so `agent-rulebook init` does not create a nonempty
|
|
90
|
-
destination before Git:
|
|
60
|
+
Canonical solutions store a stable project key, repository fingerprint, Git commit or working-tree hash, relative path, optional symbol, content hash, and test locators. Register each clone explicitly:
|
|
91
61
|
|
|
92
62
|
```bash
|
|
93
|
-
|
|
94
|
-
agent-rulebook
|
|
95
|
-
git -C ~/.agent-rulebook config remote.origin.agentRulebookPrivacy private
|
|
96
|
-
agent-rulebook sync pull
|
|
97
|
-
agent-rulebook index check
|
|
63
|
+
agent-rulebook project register my-project /absolute/path/to/clone --json
|
|
64
|
+
agent-rulebook project check my-project --json
|
|
98
65
|
```
|
|
99
66
|
|
|
100
|
-
|
|
101
|
-
the local index, rebuilding SQLite when the source count, semantic checksum, or
|
|
102
|
-
schema version differs. The SQLite database is created separately on every
|
|
103
|
-
machine and is never pulled from Git.
|
|
67
|
+
An unregistered or missing clone does not break solution retrieval. Only source lookup returns a structured unavailable response.
|
|
104
68
|
|
|
105
|
-
|
|
106
|
-
`index check --json` should report `status: ok`, `sourceCount: 0`, and
|
|
107
|
-
`indexedCount: 0`; search returns no results until the first active canonical rule
|
|
108
|
-
is committed. Do not seed a new private remote from temporary test homes or
|
|
109
|
-
fixtures—wait for a real rule or migrate a reviewed permanent source.
|
|
69
|
+
## Private sync and a new PC
|
|
110
70
|
|
|
111
|
-
|
|
71
|
+
Only use a private Git remote. Mark a verified remote before push:
|
|
112
72
|
|
|
113
73
|
```bash
|
|
114
|
-
agent-rulebook
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
git -C ~/.agent-rulebook commit -m "Update Agent Rulebook rules"
|
|
118
|
-
agent-rulebook sync push
|
|
119
|
-
agent-rulebook sync push --yes
|
|
74
|
+
git -C ~/.agent-rulebook config remote.origin.agentRulebookPrivacy private
|
|
75
|
+
agent-rulebook sync push --json
|
|
76
|
+
agent-rulebook sync push --yes --json
|
|
120
77
|
```
|
|
121
78
|
|
|
122
|
-
|
|
123
|
-
first. If it reports a conflict, resolve every listed YAML field and rebuild the
|
|
124
|
-
index before retrying.
|
|
125
|
-
|
|
126
|
-
## Lifecycle and recovery
|
|
127
|
-
|
|
128
|
-
Lifecycle changes preview by default; add `--yes` after reviewing the target:
|
|
79
|
+
Bootstrap another machine, then remap source projects separately:
|
|
129
80
|
|
|
130
81
|
```bash
|
|
131
|
-
agent-rulebook
|
|
132
|
-
|
|
133
|
-
agent-rulebook
|
|
82
|
+
AGENT_RULEBOOK_HOME=/path/to/new/home agent-rulebook sync bootstrap \
|
|
83
|
+
--remote-url <private-git-url> --private-remote-confirmed --json
|
|
84
|
+
AGENT_RULEBOOK_HOME=/path/to/new/home agent-rulebook project register my-project /path/to/new/clone --json
|
|
134
85
|
```
|
|
135
86
|
|
|
136
|
-
|
|
137
|
-
requires an existing active replacement and rejects replacement cycles. Applied
|
|
138
|
-
changes atomically replace one YAML source and rebuild SQLite, so default CLI/MCP
|
|
139
|
-
search immediately reflects the lifecycle state.
|
|
87
|
+
Bootstrap clones canonical data, validates the v3 config and allowlist, and rebuilds the local index. It does not synchronize absolute paths or source code.
|
|
140
88
|
|
|
141
|
-
|
|
89
|
+
## CLI
|
|
142
90
|
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
91
|
+
```text
|
|
92
|
+
init
|
|
93
|
+
home reset --dry-run|--execute
|
|
94
|
+
index rebuild|check
|
|
95
|
+
project register|list|check
|
|
96
|
+
resolution find|get|get-source
|
|
97
|
+
sync pull|push|bootstrap
|
|
98
|
+
mcp
|
|
147
99
|
```
|
|
148
100
|
|
|
149
|
-
|
|
150
|
-
- For Git conflicts, resolve every listed YAML file and validate it before
|
|
151
|
-
rebuilding or pushing; the tool never auto-merges rule conflicts.
|
|
152
|
-
- For a bad synced commit, create a normal `git revert <commit>` rollback, then
|
|
153
|
-
pull and rebuild. Do not restore or synchronize a SQLite file.
|
|
101
|
+
`resolution find --input request.json --json` accepts the same strict input object as `resolutions.find`.
|
|
154
102
|
|
|
155
103
|
## Development
|
|
156
104
|
|
|
157
105
|
```bash
|
|
106
|
+
npm run build
|
|
158
107
|
npm run typecheck
|
|
159
108
|
npm test
|
|
160
|
-
npm run
|
|
161
|
-
node dist/cli.js --help
|
|
162
|
-
```
|
|
163
|
-
|
|
164
|
-
Verify the publish artifact without writing to the registry:
|
|
165
|
-
|
|
166
|
-
```bash
|
|
167
|
-
npm run release:verify
|
|
168
|
-
npm pack --dry-run
|
|
109
|
+
npm run acceptance
|
|
169
110
|
npm run check:package
|
|
170
|
-
npm run smoke:package
|
|
171
111
|
```
|
|
172
112
|
|
|
173
|
-
The
|
|
174
|
-
runs CLI/init/native SQLite/MCP acceptance, then repeats from the warm cache in
|
|
175
|
-
a second isolated install. All package and rulebook homes are temporary.
|
|
176
|
-
|
|
177
|
-
The project uses `better-sqlite3` for the local SQLite store because the MVP
|
|
178
|
-
needs synchronous, embedded persistence with a small API surface. It is a native
|
|
179
|
-
dependency. Install or startup diagnostics include the exact Node version,
|
|
180
|
-
platform, and architecture so unsupported native combinations can be reported.
|
|
181
|
-
|
|
182
|
-
## Release status
|
|
183
|
-
|
|
184
|
-
The local package candidate version is `0.1.7`; the fresh preflight for this
|
|
185
|
-
candidate found published versions only through `0.1.6`. The package remains
|
|
186
|
-
explicitly `UNLICENSED`, and no public repository, homepage, or issue tracker is
|
|
187
|
-
currently advertised because the source remote is not publicly accessible.
|
|
188
|
-
Package availability and mutable registry tags must be checked again immediately
|
|
189
|
-
before publish. No publish or dist-tag operation is performed by the local
|
|
190
|
-
verification scripts, and this document does not claim `0.1.7` release success.
|
|
113
|
+
The derived index uses the pinned native `better-sqlite3` driver. The package contains compiled runtime files, this README, package metadata, and the license; tests, fixtures, source trees, local databases, and personal paths are excluded.
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { inspectRemotePrivacy, resolveRulebookHome } from '../core/index.js';
|
|
2
|
+
import { executeLegacyReset, previewLegacyReset } from '../storage/index.js';
|
|
3
|
+
import { writeJson } from './output.js';
|
|
4
|
+
export function registerHomeCommand(program) {
|
|
5
|
+
const homeCommand = program
|
|
6
|
+
.command('home')
|
|
7
|
+
.description('Manage the local Resolution Memory home');
|
|
8
|
+
homeCommand
|
|
9
|
+
.command('reset')
|
|
10
|
+
.description('Preview or execute the guarded legacy-to-v3 clean reset')
|
|
11
|
+
.option('--dry-run', 'Preview the exact deletion allowlist without writing')
|
|
12
|
+
.option('--execute', 'Execute the guarded reset')
|
|
13
|
+
.option('--expected-home <path>', 'Exact home path required for execution')
|
|
14
|
+
.option('--confirm <phrase>', 'Exact confirmation phrase required for execution')
|
|
15
|
+
.option('--json', 'Print JSON output')
|
|
16
|
+
.action(async (options) => {
|
|
17
|
+
if (options.dryRun === options.execute)
|
|
18
|
+
throw new Error('Choose exactly one of --dry-run or --execute');
|
|
19
|
+
const home = resolveRulebookHome();
|
|
20
|
+
const preview = await previewLegacyReset(home);
|
|
21
|
+
if (options.dryRun === true) {
|
|
22
|
+
emit(options, {
|
|
23
|
+
status: 'preview',
|
|
24
|
+
home: preview.home,
|
|
25
|
+
deletion_targets: preview.deletionTargets,
|
|
26
|
+
rewritten: preview.rewritten,
|
|
27
|
+
preserved: preview.preserved,
|
|
28
|
+
});
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (options.expectedHome === undefined)
|
|
32
|
+
throw new Error('--expected-home is required for execution');
|
|
33
|
+
const privacy = await inspectRemotePrivacy(home);
|
|
34
|
+
if (privacy.privacy !== 'private')
|
|
35
|
+
throw new Error('Reset requires a verified private Git remote');
|
|
36
|
+
const result = await executeLegacyReset({
|
|
37
|
+
home,
|
|
38
|
+
expectedHome: options.expectedHome,
|
|
39
|
+
confirmation: options.confirm ?? '',
|
|
40
|
+
privateGitVerified: true,
|
|
41
|
+
});
|
|
42
|
+
emit(options, {
|
|
43
|
+
status: 'reset',
|
|
44
|
+
home: result.home,
|
|
45
|
+
deleted: result.deletionTargets,
|
|
46
|
+
rewritten: result.rewritten,
|
|
47
|
+
preserved: result.preserved,
|
|
48
|
+
private_remote_verified: true,
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
return program;
|
|
52
|
+
}
|
|
53
|
+
function emit(options, value) {
|
|
54
|
+
if (options.json === true)
|
|
55
|
+
writeJson(value);
|
|
56
|
+
else
|
|
57
|
+
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=home.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"home.js","sourceRoot":"","sources":["../../src/commands/home.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAUxC,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,MAAM,WAAW,GAAG,OAAO;SACxB,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,yCAAyC,CAAC,CAAC;IAE1D,WAAW;SACR,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,yDAAyD,CAAC;SACtE,MAAM,CAAC,WAAW,EAAE,sDAAsD,CAAC;SAC3E,MAAM,CAAC,WAAW,EAAE,2BAA2B,CAAC;SAChD,MAAM,CAAC,wBAAwB,EAAE,wCAAwC,CAAC;SAC1E,MAAM,CAAC,oBAAoB,EAAE,kDAAkD,CAAC;SAChF,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC;SACrC,MAAM,CAAC,KAAK,EAAE,OAAqB,EAAE,EAAE;QACtC,IAAI,OAAO,CAAC,MAAM,KAAK,OAAO,CAAC,OAAO;YAAE,M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8B;IACjE,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI;QAAE,SAAS,CAAC,KAAK,CAAC,CAAC;;QACvC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC"}
|
package/dist/commands/index.js
CHANGED
|
@@ -1,36 +1,37 @@
|
|
|
1
1
|
import { resolveRulebookHome } from '../core/index.js';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
2
|
+
import { checkResolutionIndex, rebuildResolutionIndex } from '../storage/index.js';
|
|
3
|
+
import { writeJson } from './output.js';
|
|
4
4
|
export { registerInitCommand } from './init.js';
|
|
5
5
|
export function registerIndexCommand(program) {
|
|
6
6
|
const indexCommand = program
|
|
7
7
|
.command('index')
|
|
8
|
-
.description('Inspect and rebuild the local
|
|
8
|
+
.description('Inspect and rebuild the local Resolution Memory v3 index');
|
|
9
9
|
indexCommand
|
|
10
10
|
.command('rebuild')
|
|
11
|
-
.description('Rebuild the local
|
|
11
|
+
.description('Rebuild the local Resolution Memory v3 index')
|
|
12
12
|
.option('--json', 'Print JSON output')
|
|
13
13
|
.action(async (options) => {
|
|
14
14
|
const home = resolveRulebookHome();
|
|
15
|
-
const result = await
|
|
15
|
+
const result = await rebuildResolutionIndex({ home });
|
|
16
16
|
if (options.json === true) {
|
|
17
17
|
writeJson(result);
|
|
18
|
-
return;
|
|
19
18
|
}
|
|
20
|
-
|
|
19
|
+
else {
|
|
20
|
+
process.stdout.write(`status\t${result.status}\nindexPath\t${result.indexPath}\ncanonicalCount\t${result.canonicalCount}\nportableChecksum\t${result.portableChecksum}\n`);
|
|
21
|
+
}
|
|
21
22
|
});
|
|
22
23
|
indexCommand
|
|
23
24
|
.command('check')
|
|
24
|
-
.description('Check whether the local
|
|
25
|
+
.description('Check whether the local Resolution Memory v3 index is present and current')
|
|
25
26
|
.option('--json', 'Print JSON output')
|
|
26
27
|
.action(async (options) => {
|
|
27
28
|
const home = resolveRulebookHome();
|
|
28
|
-
const result = await
|
|
29
|
+
const result = await checkResolutionIndex(home);
|
|
29
30
|
if (options.json === true) {
|
|
30
31
|
writeJson(result);
|
|
31
32
|
}
|
|
32
33
|
else {
|
|
33
|
-
|
|
34
|
+
process.stdout.write(`${JSON.stringify(result)}\n`);
|
|
34
35
|
}
|
|
35
36
|
if (result.status !== 'ok') {
|
|
36
37
|
process.exitCode = 1;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/commands/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAEnF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,OAAO,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAMhD,MAAM,UAAU,oBAAoB,CAAC,OAAgB;IACnD,MAAM,YAAY,GAAG,OAAO;SACzB,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,0DAA0D,CAAC,CAAC;IAE3E,YAAY;SACT,OAAO,CAAC,SAAS,CAAC;SAClB,WAAW,CAAC,8CAA8C,CAAC;SAC3D,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC;SACrC,MAAM,CAAC,KAAK,EAAE,OAA2B,EAAE,EAAE;QAC5C,MAAM,IAAI,GAAG,mBAAmB,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,sBAAsB,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;QAEtD,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC1B,SAAS,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,MAAM,CAAC,MAAM,gBAAgB,MAAM,CAAC,SAAS,qBAAqB,MAAM,CAAC,cAAc,uBAAuB,MAAM,CAAC,gBAAgB,IAAI,CAAC,CAAC;QAC7K,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,YAAY;SACT,OAAO,CAAC,OAAO,CAAC;SAChB,WAAW,CAAC,2EAA2E,CAAC;SACxF,MAAM,CAAC,QAAQ,EAAE,mBAAmB,CAAC;SACrC,MAAM,CAAC,KAAK,EAAE,OAA2B,EAAE,EAAE;QAC5C,MAAM,IAAI,GAAG,mBAAmB,EAAE,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,CAAC;QAEhD,IAAI,OAAO,CAAC,IAAI,KAAK,IAAI,EAAE,CAAC;YAC1B,SAAS,CAAC,MAAM,CAAC,CAAC;QACpB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACtD,CAAC;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC3B,OAAO,CAAC,QAAQ,GAAG,CAAC,CAAC;QACvB,CAAC;IACH,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/commands/init.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
import { resolveRulebookHome } from '../core/paths.js';
|
|
2
|
-
import {
|
|
2
|
+
import { createResolutionHome } from '../storage/resolution-home.js';
|
|
3
3
|
export function registerInitCommand(program) {
|
|
4
4
|
program
|
|
5
5
|
.command('init')
|
|
6
6
|
.description('Create the local Agent Rulebook home layout')
|
|
7
7
|
.action(async () => {
|
|
8
8
|
const home = resolveRulebookHome();
|
|
9
|
-
|
|
10
|
-
process.stdout.write(`
|
|
11
|
-
for (const entry of result.entries) {
|
|
12
|
-
process.stdout.write(`${entry.status}\t${entry.kind}\t${entry.relativePath}\n`);
|
|
13
|
-
}
|
|
9
|
+
await createResolutionHome(home);
|
|
10
|
+
process.stdout.write(`Resolution home initialized: ${home}\n`);
|
|
14
11
|
});
|
|
15
12
|
return program;
|
|
16
13
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/commands/init.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AAErE,MAAM,UAAU,mBAAmB,CAAC,OAAgB;IAClD,OAAO;SACJ,OAAO,CAAC,MAAM,CAAC;SACf,WAAW,CAAC,6CAA6C,CAAC;SAC1D,MAAM,CAAC,KAAK,IAAI,EAAE;QACjB,MAAM,IAAI,GAAG,mBAAmB,EAAE,CAAC;QACnC,MAAM,oBAAoB,CAAC,IAAI,CAAC,CAAC;QACjC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,gCAAgC,IAAI,IAAI,CAAC,CAAC;IACjE,CAAC,CAAC,CAAC;IAEL,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
|
@@ -1,6 +1 @@
|
|
|
1
|
-
import type { IndexCheckResult, RebuildRulebookIndexResult } from '../storage/index.js';
|
|
2
|
-
import type { SearchResponse } from '../core/index.js';
|
|
3
1
|
export declare function writeJson(value: unknown): void;
|
|
4
|
-
export declare function writeSearchText(response: SearchResponse): void;
|
|
5
|
-
export declare function writeIndexRebuildText(result: RebuildRulebookIndexResult): void;
|
|
6
|
-
export declare function writeIndexCheckText(result: IndexCheckResult): void;
|
package/dist/commands/output.js
CHANGED
|
@@ -1,51 +1,4 @@
|
|
|
1
1
|
export function writeJson(value) {
|
|
2
2
|
process.stdout.write(`${JSON.stringify(value, null, 2)}\n`);
|
|
3
3
|
}
|
|
4
|
-
export function writeSearchText(response) {
|
|
5
|
-
if (response.results.length === 0) {
|
|
6
|
-
process.stdout.write(`${response.hint ?? 'No results'}\n`);
|
|
7
|
-
return;
|
|
8
|
-
}
|
|
9
|
-
process.stdout.write('score\tstatus\tconfidence\tid\ttitle\n');
|
|
10
|
-
for (const result of response.results) {
|
|
11
|
-
process.stdout.write(formatSearchResult(result));
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
export function writeIndexRebuildText(result) {
|
|
15
|
-
process.stdout.write(`indexPath\t${result.indexPath}\n`);
|
|
16
|
-
process.stdout.write(`indexed\t${result.indexedCount}\n`);
|
|
17
|
-
if (result.skipped.length === 0) {
|
|
18
|
-
process.stdout.write('skipped\t0\n');
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
for (const skipped of result.skipped) {
|
|
22
|
-
process.stdout.write(`skipped\t${skipped.path}\t${skipped.reason}\n`);
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
export function writeIndexCheckText(result) {
|
|
26
|
-
process.stdout.write(`status\t${result.status}\n`);
|
|
27
|
-
process.stdout.write(`sourceCount\t${result.sourceCount}\n`);
|
|
28
|
-
process.stdout.write(`indexedCount\t${result.indexedCount}\n`);
|
|
29
|
-
process.stdout.write(`sourceChecksum\t${result.sourceChecksum}\n`);
|
|
30
|
-
process.stdout.write(`indexedChecksum\t${result.indexedChecksum ?? 'unavailable'}\n`);
|
|
31
|
-
process.stdout.write(`indexPath\t${result.indexPath}\n`);
|
|
32
|
-
if (result.runtime !== undefined) {
|
|
33
|
-
process.stdout.write(`userVersion\t${result.runtime.userVersion}\n`);
|
|
34
|
-
process.stdout.write(`expectedUserVersion\t${result.runtime.expectedUserVersion}\n`);
|
|
35
|
-
process.stdout.write(`fts5Available\t${result.runtime.fts5Available}\n`);
|
|
36
|
-
process.stdout.write(`integrity\t${result.runtime.integrity}\n`);
|
|
37
|
-
}
|
|
38
|
-
if (result.hint !== undefined) {
|
|
39
|
-
process.stdout.write(`hint\t${result.hint}\n`);
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function formatSearchResult(result) {
|
|
43
|
-
return [
|
|
44
|
-
`${result.score.toFixed(3)}\t${result.status}\t${result.confidence}\t${result.id}\t${result.title}`,
|
|
45
|
-
`summary\t${result.summary}`,
|
|
46
|
-
`fix\t${result.fix}`,
|
|
47
|
-
`path\t${result.path}`,
|
|
48
|
-
'',
|
|
49
|
-
].join('\n');
|
|
50
|
-
}
|
|
51
4
|
//# sourceMappingURL=output.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/commands/output.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"output.js","sourceRoot":"","sources":["../../src/commands/output.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,KAAc;IACtC,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAAC,CAAC;AAC9D,CAAC"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { inspectRepositoryIdentity, readProjectRegistry, registerProject, resolveRulebookHome } from '../core/index.js';
|
|
2
|
+
import { writeJson } from './output.js';
|
|
3
|
+
export function registerProjectCommand(program) {
|
|
4
|
+
const project = program.command('project').description('Manage machine-local project mappings');
|
|
5
|
+
project.command('register')
|
|
6
|
+
.argument('<key>')
|
|
7
|
+
.argument('<root>')
|
|
8
|
+
.option('--json')
|
|
9
|
+
.action(async (key, root, options) => {
|
|
10
|
+
const identity = await inspectRepositoryIdentity(root);
|
|
11
|
+
const registry = await registerProject(resolveRulebookHome(), key, identity.root);
|
|
12
|
+
emit({ status: 'registered', key, root: registry.projects[key], repository_fingerprint: identity.fingerprint }, options.json);
|
|
13
|
+
});
|
|
14
|
+
project.command('list').option('--json').action(async (options) => {
|
|
15
|
+
emit(await readProjectRegistry(resolveRulebookHome()), options.json);
|
|
16
|
+
});
|
|
17
|
+
project.command('check').argument('<key>').option('--json').action(async (key, options) => {
|
|
18
|
+
const registry = await readProjectRegistry(resolveRulebookHome());
|
|
19
|
+
const root = registry.projects[key];
|
|
20
|
+
const result = root === undefined
|
|
21
|
+
? { status: 'unavailable', code: 'project_unregistered', key }
|
|
22
|
+
: { status: 'ok', key, ...(await inspectRepositoryIdentity(root)) };
|
|
23
|
+
emit(result, options.json);
|
|
24
|
+
});
|
|
25
|
+
return program;
|
|
26
|
+
}
|
|
27
|
+
function emit(value, json) {
|
|
28
|
+
if (json === true)
|
|
29
|
+
writeJson(value);
|
|
30
|
+
else
|
|
31
|
+
process.stdout.write(`${JSON.stringify(value)}\n`);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=project.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"project.js","sourceRoot":"","sources":["../../src/commands/project.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,mBAAmB,EAAE,eAAe,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACxH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,UAAU,sBAAsB,CAAC,OAAgB;IACrD,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,uCAAuC,CAAC,CAAC;IAChG,OAAO,CAAC,OAAO,CAAC,UAAU,CAAC;SACxB,QAAQ,CAAC,OAAO,CAAC;SACjB,QAAQ,CAAC,QAAQ,CAAC;SAClB,MAAM,CAAC,QAAQ,CAAC;SAChB,MAAM,CAAC,KAAK,EAAE,GAAW,EA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I,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IAC7B,CAAC,CAAC,CAAC;IACH,OAAO,OAAO,CAAC;AACjB,CAAC;AAED,SAAS,IAAI,CAAC,KAAc,EAAE,IAAc;IAC1C,IAAI,IAAI,KAAK,IAAI;QAAE,SAAS,CAAC,KAAK,CAAC,CAAC;;QAC/B,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { readFile } from 'node:fs/promises';
|
|
2
|
+
import { resolveRulebookHome } from '../core/index.js';
|
|
3
|
+
import { McpResolutionsFindInputSchema } from '../mcp/schemas.js';
|
|
4
|
+
import { handleResolutionsFind } from '../mcp/resolutions-find-tool.js';
|
|
5
|
+
import { handleResolutionsGet } from '../mcp/resolutions-get-tool.js';
|
|
6
|
+
import { handleResolutionsGetSource } from '../mcp/resolutions-get-source-tool.js';
|
|
7
|
+
import { writeJson } from './output.js';
|
|
8
|
+
export function registerResolutionCommand(program) {
|
|
9
|
+
const resolution = program.command('resolution').description('Find and inspect Resolution Memory v3 solutions');
|
|
10
|
+
resolution.command('find').requiredOption('--input <json>', 'JSON file containing a resolutions.find request').option('--json').action(async (options) => {
|
|
11
|
+
const input = McpResolutionsFindInputSchema.parse(JSON.parse(await readFile(options.input, 'utf8')));
|
|
12
|
+
emit(await handleResolutionsFind(input, { rulebookHome: resolveRulebookHome() }), options.json);
|
|
13
|
+
});
|
|
14
|
+
resolution.command('get').argument('<solution-handle>').option('--json').action(async (solutionHandle, options) => {
|
|
15
|
+
emit(await handleResolutionsGet({ solution_handle: solutionHandle }, { rulebookHome: resolveRulebookHome() }), options.json);
|
|
16
|
+
});
|
|
17
|
+
resolution.command('get-source').argument('<solution-handle>').argument('<source-handle>').option('--json').action(async (solutionHandle, sourceHandle, options) => {
|
|
18
|
+
emit(await handleResolutionsGetSource({ solution_handle: solutionHandle, source_handle: sourceHandle }, { rulebookHome: resolveRulebookHome() }), options.json);
|
|
19
|
+
});
|
|
20
|
+
return program;
|
|
21
|
+
}
|
|
22
|
+
function emit(result, json) {
|
|
23
|
+
const block = result.content[0];
|
|
24
|
+
if (block?.type !== 'text')
|
|
25
|
+
throw new Error('Resolution command expected JSON text output');
|
|
26
|
+
const parsed = JSON.parse(block.text ?? '');
|
|
27
|
+
if (json === true)
|
|
28
|
+
writeJson(parsed);
|
|
29
|
+
else
|
|
30
|
+
process.stdout.write(`${JSON.stringify(parsed)}\n`);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=resolution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolution.js","sourceRoot":"","sources":["../../src/commands/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,6BAA6B,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,EAAE,qBAAqB,EAAE,MAAM,iCAAiC,CAAC;AACxE,OAAO,EAAE,oBAAoB,EAAE,MAAM,gCAAgC,CAAC;AACtE,OAAO,EAAE,0BAA0B,EAAE,MAAM,uCAAuC,CAAC;AACnF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,MAAM,UAAU,yBAAyB,CAAC,OAAgB;IACxD,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC,WAAW,CAAC,iDAAiD,CAAC,CAAC;IAChH,UAAU,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,cAAc,CAAC,gBAAgB,EAAE,iDAAiD,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,OAA0C,EAAE,EAAE;QAC1L,MAAM,KAAK,GAAG,6BAA6B,CA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M,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;IAC5F,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAC5C,IAAI,IAAI,KAAK,IAAI;QAAE,SAAS,CAAC,MAAM,CAAC,CAAC;;QAAM,OAAO,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;AACjG,CAAC"}
|
package/dist/commands/sync.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { Command } from 'commander';
|
|
2
|
-
import {
|
|
2
|
+
import { checkResolutionIndex } from '../storage/index.js';
|
|
3
3
|
export type SyncIssue = {
|
|
4
4
|
code: string;
|
|
5
5
|
message: string;
|
|
@@ -7,13 +7,16 @@ export type SyncIssue = {
|
|
|
7
7
|
fields?: string[];
|
|
8
8
|
};
|
|
9
9
|
export type SyncResult = {
|
|
10
|
-
status: 'blocked' | 'failed' | 'preview' | 'pulled' | 'pushed';
|
|
10
|
+
status: 'blocked' | 'failed' | 'preview' | 'pulled' | 'pushed' | 'bootstrapped';
|
|
11
11
|
remote: string;
|
|
12
12
|
remoteUrl?: string;
|
|
13
13
|
changedFiles: string[];
|
|
14
14
|
issues: SyncIssue[];
|
|
15
|
-
index?: Awaited<ReturnType<typeof
|
|
15
|
+
index?: Awaited<ReturnType<typeof checkResolutionIndex>>;
|
|
16
|
+
remapRequired?: boolean;
|
|
17
|
+
nextSteps?: string[];
|
|
16
18
|
};
|
|
17
19
|
export declare function registerSyncCommand(program: Command): Command;
|
|
18
20
|
export declare function syncPush(home: string, remote?: string, confirmed?: boolean): Promise<SyncResult>;
|
|
19
21
|
export declare function syncPull(home: string, remote?: string): Promise<SyncResult>;
|
|
22
|
+
export declare function syncBootstrap(home: string, remoteUrl: string, remote?: string, privateRemoteConfirmed?: boolean): Promise<SyncResult>;
|