nexus-canon 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +2 -0
- package/README.md +30 -0
- package/bin/nexus-canon.js +3 -0
- package/dist/canonArtifacts.d.ts +14 -0
- package/dist/canonArtifacts.d.ts.map +1 -0
- package/dist/canonArtifacts.js +269 -0
- package/dist/canonArtifacts.js.map +1 -0
- package/dist/canonGraph.d.ts +30 -0
- package/dist/canonGraph.d.ts.map +1 -0
- package/dist/canonGraph.js +216 -0
- package/dist/canonGraph.js.map +1 -0
- package/dist/canonInit.d.ts +15 -0
- package/dist/canonInit.d.ts.map +1 -0
- package/dist/canonInit.js +65 -0
- package/dist/canonInit.js.map +1 -0
- package/dist/canonPull.d.ts +38 -0
- package/dist/canonPull.d.ts.map +1 -0
- package/dist/canonPull.js +133 -0
- package/dist/canonPull.js.map +1 -0
- package/dist/canonSync.d.ts +20 -0
- package/dist/canonSync.d.ts.map +1 -0
- package/dist/canonSync.js +243 -0
- package/dist/canonSync.js.map +1 -0
- package/dist/canonTranslate.d.ts +19 -0
- package/dist/canonTranslate.d.ts.map +1 -0
- package/dist/canonTranslate.js +719 -0
- package/dist/canonTranslate.js.map +1 -0
- package/dist/cli.d.ts +2 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +71 -0
- package/dist/cli.js.map +1 -0
- package/dist/index.d.ts +28 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/index.js.map +1 -0
- package/dist/scaffoldAssets.d.ts +20 -0
- package/dist/scaffoldAssets.d.ts.map +1 -0
- package/dist/scaffoldAssets.js +31 -0
- package/dist/scaffoldAssets.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
|
|
2
|
+
Apache License
|
|
3
|
+
Version 2.0, January 2004
|
|
4
|
+
http://www.apache.org/licenses/
|
|
5
|
+
|
|
6
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
7
|
+
|
|
8
|
+
1. Definitions.
|
|
9
|
+
|
|
10
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
11
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
12
|
+
|
|
13
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
14
|
+
the copyright owner that is granting the License.
|
|
15
|
+
|
|
16
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
17
|
+
other entities that control, are controlled by, or are under common
|
|
18
|
+
control with that entity. For the purposes of this definition,
|
|
19
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
20
|
+
direction or management of such entity, whether by contract or
|
|
21
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
22
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
23
|
+
|
|
24
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
25
|
+
exercising permissions granted by this License.
|
|
26
|
+
|
|
27
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
28
|
+
including but not limited to software source code, documentation
|
|
29
|
+
source, and configuration files.
|
|
30
|
+
|
|
31
|
+
"Object" form shall mean any form resulting from mechanical
|
|
32
|
+
transformation or translation of a Source form, including but
|
|
33
|
+
not limited to compiled object code, generated documentation,
|
|
34
|
+
and conversions to other media types.
|
|
35
|
+
|
|
36
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
37
|
+
Object form, made available under the License, as indicated by a
|
|
38
|
+
copyright notice that is included in or attached to the work
|
|
39
|
+
(an example is provided in the Appendix below).
|
|
40
|
+
|
|
41
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
42
|
+
form, that is based on (or derived from) the Work and for which the
|
|
43
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
44
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
45
|
+
of this License, Derivative Works shall not include works that remain
|
|
46
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
47
|
+
the Work and Derivative Works thereof.
|
|
48
|
+
|
|
49
|
+
"Contribution" shall mean any work of authorship, including
|
|
50
|
+
the original version of the Work and any modifications or additions
|
|
51
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
52
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
53
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
54
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
55
|
+
means any form of electronic, verbal, or written communication sent
|
|
56
|
+
to the Licensor or its representatives, including but not limited to
|
|
57
|
+
communication on electronic mailing lists, source code control systems,
|
|
58
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
59
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
60
|
+
excluding communication that is conspicuously marked or otherwise
|
|
61
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
62
|
+
|
|
63
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
64
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
65
|
+
subsequently incorporated within the Work.
|
|
66
|
+
|
|
67
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
68
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
69
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
70
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
71
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
72
|
+
Work and such Derivative Works in Source or Object form.
|
|
73
|
+
|
|
74
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
75
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
76
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
77
|
+
(except as stated in this section) patent license to make, have made,
|
|
78
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
79
|
+
where such license applies only to those patent claims licensable
|
|
80
|
+
by such Contributor that are necessarily infringed by their
|
|
81
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
82
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
83
|
+
institute patent litigation against any entity (including a
|
|
84
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
85
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
86
|
+
or contributory patent infringement, then any patent licenses
|
|
87
|
+
granted to You under this License for that Work shall terminate
|
|
88
|
+
as of the date such litigation is filed.
|
|
89
|
+
|
|
90
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
91
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
92
|
+
modifications, and in Source or Object form, provided that You
|
|
93
|
+
meet the following conditions:
|
|
94
|
+
|
|
95
|
+
(a) You must give any other recipients of the Work or
|
|
96
|
+
Derivative Works a copy of this License; and
|
|
97
|
+
|
|
98
|
+
(b) You must cause any modified files to carry prominent notices
|
|
99
|
+
stating that You changed the files; and
|
|
100
|
+
|
|
101
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
102
|
+
that You distribute, all copyright, patent, trademark, and
|
|
103
|
+
attribution notices from the Source form of the Work,
|
|
104
|
+
excluding those notices that do not pertain to any part of
|
|
105
|
+
the Derivative Works; and
|
|
106
|
+
|
|
107
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
108
|
+
distribution, then any Derivative Works that You distribute must
|
|
109
|
+
include a readable copy of the attribution notices contained
|
|
110
|
+
within such NOTICE file, excluding those notices that do not
|
|
111
|
+
pertain to any part of the Derivative Works, in at least one
|
|
112
|
+
of the following places: within a NOTICE text file distributed
|
|
113
|
+
as part of the Derivative Works; within the Source form or
|
|
114
|
+
documentation, if provided along with the Derivative Works; or,
|
|
115
|
+
within a display generated by the Derivative Works, if and
|
|
116
|
+
wherever such third-party notices normally appear. The contents
|
|
117
|
+
of the NOTICE file are for informational purposes only and
|
|
118
|
+
do not modify the License. You may add Your own attribution
|
|
119
|
+
notices within Derivative Works that You distribute, alongside
|
|
120
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
121
|
+
that such additional attribution notices cannot be construed
|
|
122
|
+
as modifying the License.
|
|
123
|
+
|
|
124
|
+
You may add Your own copyright statement to Your modifications and
|
|
125
|
+
may provide additional or different license terms and conditions
|
|
126
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
127
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
128
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
129
|
+
the conditions stated in this License.
|
|
130
|
+
|
|
131
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
132
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
133
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
134
|
+
this License, without any additional terms or conditions.
|
|
135
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
136
|
+
the terms of any separate license agreement you may have executed
|
|
137
|
+
with Licensor regarding such Contributions.
|
|
138
|
+
|
|
139
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
140
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
141
|
+
except as required for reasonable and customary use in describing the
|
|
142
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
143
|
+
|
|
144
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
145
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
146
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
147
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
148
|
+
implied, including, without limitation, any warranties or conditions
|
|
149
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
150
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
151
|
+
appropriateness of using or redistributing the Work and assume any
|
|
152
|
+
risks associated with Your exercise of permissions under this License.
|
|
153
|
+
|
|
154
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
155
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
156
|
+
unless required by applicable law (such as deliberate and grossly
|
|
157
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
158
|
+
liable to You for damages, including any direct, indirect, special,
|
|
159
|
+
incidental, or consequential damages of any character arising as a
|
|
160
|
+
result of this License or out of the use or inability to use the
|
|
161
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
162
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
163
|
+
other commercial damages or losses), even if such Contributor
|
|
164
|
+
has been advised of the possibility of such damages.
|
|
165
|
+
|
|
166
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
167
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
168
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
169
|
+
or other liability obligations and/or rights consistent with this
|
|
170
|
+
License. However, in accepting such obligations, You may act only
|
|
171
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
172
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
173
|
+
defend, and hold each Contributor harmless for any liability
|
|
174
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
175
|
+
of your accepting any such warranty or additional liability.
|
|
176
|
+
|
|
177
|
+
END OF TERMS AND CONDITIONS
|
|
178
|
+
|
|
179
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
180
|
+
|
|
181
|
+
To apply the Apache License to your work, attach the following
|
|
182
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
183
|
+
replaced with your own identifying information. (Don't include
|
|
184
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
185
|
+
comment syntax for the file format. We also recommend that a
|
|
186
|
+
file or class name and description of purpose be included on the
|
|
187
|
+
same "printed page" as the copyright notice for easier
|
|
188
|
+
identification within third-party archives.
|
|
189
|
+
|
|
190
|
+
Copyright [yyyy] [name of copyright owner]
|
|
191
|
+
|
|
192
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
193
|
+
you may not use this file except in compliance with the License.
|
|
194
|
+
You may obtain a copy of the License at
|
|
195
|
+
|
|
196
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
197
|
+
|
|
198
|
+
Unless required by applicable law or agreed to in writing, software
|
|
199
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
200
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
201
|
+
See the License for the specific language governing permissions and
|
|
202
|
+
limitations under the License.
|
package/NOTICE
ADDED
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# nexus-canon
|
|
2
|
+
|
|
3
|
+
**Portable agent memory in a git repo you own.**
|
|
4
|
+
|
|
5
|
+
Canon stores agent sessions in a provider-neutral, lossless, append-only canonical
|
|
6
|
+
format and translates at the edges — so the same history serves any model, any
|
|
7
|
+
provider, and any harness. This package is the standalone pipeline: scaffold a
|
|
8
|
+
store, sync native harness session files into it, maintain the canonical line,
|
|
9
|
+
and pull sessions back out wherever you want to resume. Capability artifacts
|
|
10
|
+
(skills, agents, MCP configs) and project-scoped knowledge graphs ride the same
|
|
11
|
+
store.
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm i -g nexus-canon
|
|
15
|
+
nexus-canon init my-canon --remote <private-repo-url>
|
|
16
|
+
nexus-canon sync && nexus-canon translate
|
|
17
|
+
nexus-canon list
|
|
18
|
+
nexus-canon pull <session-uuid> --to .cortex/sessions
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Dependency-free (Node built-ins; canonical record types from
|
|
22
|
+
`@nexus-cortex/types`). The [nexus-cortex](https://www.npmjs.com/package/nexus-cortex)
|
|
23
|
+
harness embeds this same package as `cortex canon <verb>` — one implementation
|
|
24
|
+
everywhere.
|
|
25
|
+
|
|
26
|
+
**Spec:** [docs/CANON.md](https://github.com/Spitfire-Products/nexus-cortex/blob/main/docs/CANON.md)
|
|
27
|
+
— the record format, the contract (store once / translate at the edge /
|
|
28
|
+
append-only / provenance recorded), the artifact dimension, and honest scope.
|
|
29
|
+
|
|
30
|
+
License: Apache-2.0.
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export interface CanonArtifactsOptions {
|
|
2
|
+
store?: string;
|
|
3
|
+
home?: string;
|
|
4
|
+
dryRun?: boolean;
|
|
5
|
+
repoUrl?: string;
|
|
6
|
+
}
|
|
7
|
+
export interface CanonArtifactsResult {
|
|
8
|
+
captured: number;
|
|
9
|
+
unchanged: number;
|
|
10
|
+
kinds: Record<string, number>;
|
|
11
|
+
pushed: boolean;
|
|
12
|
+
}
|
|
13
|
+
export declare function canonArtifacts(o?: CanonArtifactsOptions): Promise<CanonArtifactsResult>;
|
|
14
|
+
//# sourceMappingURL=canonArtifacts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonArtifacts.d.ts","sourceRoot":"","sources":["../src/canonArtifacts.ts"],"names":[],"mappings":"AA0BA,MAAM,WAAW,qBAAqB;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,MAAM,EAAE,OAAO,CAAC;CACjB;AAuCD,wBAAsB,cAAc,CAAC,CAAC,GAAE,qBAA0B,GAAG,OAAO,CAAC,oBAAoB,CAAC,CAqLjG"}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* canonArtifacts — the capability/artifact dimension capture leg
|
|
3
|
+
* (CANON_CROSS_HARNESS_PLAN.md §27p; Phase C part 2, leg 3).
|
|
4
|
+
*
|
|
5
|
+
* Discovers native capability artifacts and the intent layer, normalizes each
|
|
6
|
+
* into the store's taxonomy dirs (the CAPTURE side of the per-kind layout
|
|
7
|
+
* adapters: skill-dir → /skills/<id>/, agent-file → /agents/<id>.md,
|
|
8
|
+
* mcp/plugin registries → normalized JSON, project manifests → JSON with a
|
|
9
|
+
* thin `state` field), and writes one ArtifactManifest record per artifact
|
|
10
|
+
* under /canon/artifacts/<kind>/<id>.json. Content is blob-addressed with git
|
|
11
|
+
* blob SHAs computed locally (sha1 of "blob <len>\0"+bytes — identical to
|
|
12
|
+
* git's object id, so provenance survives any clone). Secret scrub at the
|
|
13
|
+
* push boundary, same pattern set as canonSync. Absences are VISIBLE in
|
|
14
|
+
* /canon/artifacts/ARTIFACTS.md (D8: never silent). Incremental via
|
|
15
|
+
* ~/.canon/artifacts-manifest.json keyed by primary-file blob refs.
|
|
16
|
+
* Projection-BACK (store → receiving harness layout) arrives with the
|
|
17
|
+
* artifact pull leg; stated in ARTIFACTS.md rather than implied.
|
|
18
|
+
*
|
|
19
|
+
* @module canon/canonArtifacts
|
|
20
|
+
*/
|
|
21
|
+
import * as crypto from 'node:crypto';
|
|
22
|
+
import * as fs from 'node:fs';
|
|
23
|
+
import * as path from 'node:path';
|
|
24
|
+
import { execFileSync } from 'node:child_process';
|
|
25
|
+
const SECRET_PATTERNS = [
|
|
26
|
+
[/sk-[A-Za-z0-9_-]{16,}/g, '[redacted:sk]'],
|
|
27
|
+
[/ghp_[A-Za-z0-9]{20,}/g, '[redacted:ghp]'],
|
|
28
|
+
[/github_pat_[A-Za-z0-9_]{20,}/g, '[redacted:ghpat]'],
|
|
29
|
+
[/hf_[A-Za-z0-9]{20,}/g, '[redacted:hf]'],
|
|
30
|
+
[/AIza[A-Za-z0-9_-]{20,}/g, '[redacted:aiza]'],
|
|
31
|
+
[/xai-[A-Za-z0-9]{20,}/g, '[redacted:xai]'],
|
|
32
|
+
[/nar_[A-Za-z0-9]{16,}/g, '[redacted:nar]'],
|
|
33
|
+
[/gsk_[A-Za-z0-9]{20,}/g, '[redacted:gsk]'],
|
|
34
|
+
[/xox[bpars]-[A-Za-z0-9-]{10,}/g, '[redacted:slack]'],
|
|
35
|
+
[/AKIA[A-Z0-9]{16}/g, '[redacted:akia]'],
|
|
36
|
+
[/eyJ[A-Za-z0-9_-]{20,}\.eyJ[A-Za-z0-9_-]{20,}\.[A-Za-z0-9_-]{10,}/g, '[redacted:jwt]'],
|
|
37
|
+
];
|
|
38
|
+
const scrub = (s) => SECRET_PATTERNS.reduce((v, [re, sub]) => v.replace(re, sub), s);
|
|
39
|
+
/** git blob id (12 hex) computed locally — identical to `git hash-object`. */
|
|
40
|
+
const blobRef = (content) => {
|
|
41
|
+
const buf = Buffer.isBuffer(content) ? content : Buffer.from(content);
|
|
42
|
+
return crypto.createHash('sha1')
|
|
43
|
+
.update(`blob ${buf.length}\0`).update(buf).digest('hex').slice(0, 12);
|
|
44
|
+
};
|
|
45
|
+
const walkFiles = (dir) => {
|
|
46
|
+
const out = [];
|
|
47
|
+
const rec = (d) => {
|
|
48
|
+
let es = [];
|
|
49
|
+
try {
|
|
50
|
+
es = fs.readdirSync(d, { withFileTypes: true });
|
|
51
|
+
}
|
|
52
|
+
catch {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
for (const e of es) {
|
|
56
|
+
const p = path.join(d, e.name);
|
|
57
|
+
if (e.isDirectory())
|
|
58
|
+
rec(p);
|
|
59
|
+
else if (e.isFile())
|
|
60
|
+
out.push(p);
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
rec(dir);
|
|
64
|
+
return out.sort();
|
|
65
|
+
};
|
|
66
|
+
export async function canonArtifacts(o = {}) {
|
|
67
|
+
const HOME = o.home ?? process.env.HOME ?? '/home/runner/workspace';
|
|
68
|
+
const DRY = o.dryRun ?? false;
|
|
69
|
+
const STORE = o.store ?? '/tmp/canon-store';
|
|
70
|
+
const MANIFEST_PATH = path.join(HOME, '.canon', 'artifacts-manifest.json');
|
|
71
|
+
const CANON_REPO = o.repoUrl ?? process.env.CANON_REPO ?? 'https://github.com/Spitfire-Products/nexus-canon-store';
|
|
72
|
+
const env = { ...process.env, GIT_TERMINAL_PROMPT: '0' };
|
|
73
|
+
if (!fs.existsSync(path.join(STORE, '.git'))) {
|
|
74
|
+
console.log(`[canon-artifacts] no store at ${STORE} — cloning ${CANON_REPO}`);
|
|
75
|
+
execFileSync('git', ['clone', '-q', CANON_REPO, STORE], { encoding: 'utf8', env });
|
|
76
|
+
}
|
|
77
|
+
const incr = fs.existsSync(MANIFEST_PATH)
|
|
78
|
+
? JSON.parse(fs.readFileSync(MANIFEST_PATH, 'utf8')) : {};
|
|
79
|
+
let captured = 0, unchanged = 0;
|
|
80
|
+
const kinds = {};
|
|
81
|
+
const absences = [];
|
|
82
|
+
/** Normalize one artifact into the store + write its manifest record. */
|
|
83
|
+
const capture = (m, files) => {
|
|
84
|
+
const primaryFile = files.find((f) => f.rel === m.primary);
|
|
85
|
+
if (!primaryFile)
|
|
86
|
+
return;
|
|
87
|
+
const version = blobRef(primaryFile.bytes);
|
|
88
|
+
const key = `${m.kind}/${m.id}`;
|
|
89
|
+
kinds[m.kind] = (kinds[m.kind] ?? 0) + 1;
|
|
90
|
+
if (incr[key] === version) {
|
|
91
|
+
unchanged++;
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (!DRY) {
|
|
95
|
+
const destRoot = m.kind === 'skill' || m.kind === 'plugin'
|
|
96
|
+
? path.join(STORE, m.kind + 's', m.id)
|
|
97
|
+
: path.join(STORE, m.kind === 'mcp' ? 'mcp' : m.kind + 's');
|
|
98
|
+
const content = [];
|
|
99
|
+
for (const f of files) {
|
|
100
|
+
const scrubbed = Buffer.from(scrub(f.bytes.toString('utf8')));
|
|
101
|
+
const dest = m.kind === 'skill' || m.kind === 'plugin'
|
|
102
|
+
? path.join(destRoot, f.rel)
|
|
103
|
+
: path.join(destRoot, f.rel);
|
|
104
|
+
fs.mkdirSync(path.dirname(dest), { recursive: true });
|
|
105
|
+
fs.writeFileSync(dest, scrubbed);
|
|
106
|
+
content.push({ path: f.rel, ref: blobRef(scrubbed), bytes: scrubbed.length });
|
|
107
|
+
}
|
|
108
|
+
const record = {
|
|
109
|
+
recordKind: 'artifact-manifest',
|
|
110
|
+
...m,
|
|
111
|
+
version,
|
|
112
|
+
timestamp: new Date().toISOString(),
|
|
113
|
+
content,
|
|
114
|
+
};
|
|
115
|
+
const recPath = path.join(STORE, 'canon', 'artifacts', m.kind, `${m.id}.json`);
|
|
116
|
+
fs.mkdirSync(path.dirname(recPath), { recursive: true });
|
|
117
|
+
fs.writeFileSync(recPath, JSON.stringify(record, null, 2) + '\n');
|
|
118
|
+
}
|
|
119
|
+
incr[key] = version;
|
|
120
|
+
captured++;
|
|
121
|
+
};
|
|
122
|
+
// ── skills: dir + SKILL.md (layout adapter: skill-dir → /skills/<id>/) ─────
|
|
123
|
+
for (const [harness, root] of [['claude-code', path.join(HOME, '.claude', 'skills')], ['agents-dir', path.join(HOME, '.agents', 'skills')]]) {
|
|
124
|
+
let entries = [];
|
|
125
|
+
try {
|
|
126
|
+
entries = fs.readdirSync(root);
|
|
127
|
+
}
|
|
128
|
+
catch {
|
|
129
|
+
absences.push(`${harness} skills root absent (${root})`);
|
|
130
|
+
continue;
|
|
131
|
+
}
|
|
132
|
+
for (const name of entries.sort()) {
|
|
133
|
+
const dir = path.join(root, name);
|
|
134
|
+
if (!fs.existsSync(path.join(dir, 'SKILL.md')))
|
|
135
|
+
continue;
|
|
136
|
+
const files = walkFiles(dir).map((p) => ({ rel: path.relative(dir, p), bytes: fs.readFileSync(p) }));
|
|
137
|
+
const desc = /^description:\s*(.+)$/m.exec(fs.readFileSync(path.join(dir, 'SKILL.md'), 'utf8'))?.[1];
|
|
138
|
+
capture({
|
|
139
|
+
kind: 'skill', id: name, name, description: desc?.slice(0, 200), primary: 'SKILL.md',
|
|
140
|
+
provenance: { harness, native: dir, ref: blobRef(fs.readFileSync(path.join(dir, 'SKILL.md'))) },
|
|
141
|
+
harnessCompat: { 'claude-code': 'supported', 'nexus-cortex': 'supported' },
|
|
142
|
+
projectionRules: { 'claude-code': '.claude/skills/<id>/', 'agents-dir': '.agents/skills/<id>/' },
|
|
143
|
+
}, files);
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
// ── agents: single .md w/ frontmatter (layout adapter: file → /agents/) ────
|
|
147
|
+
const agentsRoot = path.join(HOME, '.claude', 'agents');
|
|
148
|
+
let agentFiles = [];
|
|
149
|
+
try {
|
|
150
|
+
agentFiles = fs.readdirSync(agentsRoot).filter((f) => f.endsWith('.md')).sort();
|
|
151
|
+
}
|
|
152
|
+
catch {
|
|
153
|
+
absences.push(`claude-code agents root absent (${agentsRoot})`);
|
|
154
|
+
}
|
|
155
|
+
for (const f of agentFiles) {
|
|
156
|
+
const abs = path.join(agentsRoot, f);
|
|
157
|
+
const bytes = fs.readFileSync(abs);
|
|
158
|
+
const id = path.basename(f, '.md');
|
|
159
|
+
const desc = /^description:\s*(.+)$/m.exec(bytes.toString('utf8'))?.[1];
|
|
160
|
+
capture({
|
|
161
|
+
kind: 'agent', id, name: id, description: desc?.slice(0, 200), primary: f,
|
|
162
|
+
provenance: { harness: 'claude-code', native: abs, ref: blobRef(bytes) },
|
|
163
|
+
harnessCompat: { 'claude-code': 'supported' },
|
|
164
|
+
projectionRules: { 'claude-code': '.claude/agents/<id>.md' },
|
|
165
|
+
}, [{ rel: f, bytes }]);
|
|
166
|
+
}
|
|
167
|
+
// ── mcp: config registries (normalized json) ───────────────────────────────
|
|
168
|
+
const mcpSources = [
|
|
169
|
+
['workspace', path.join(HOME, '.mcp.json')],
|
|
170
|
+
['nexus-terminal', path.join(HOME, 'nexus-terminal', '.mcp.json')],
|
|
171
|
+
['omniclaude-v4', path.join(HOME, 'omniclaude-v4', '.mcp.json')],
|
|
172
|
+
];
|
|
173
|
+
for (const [label, p] of mcpSources) {
|
|
174
|
+
if (!fs.existsSync(p)) {
|
|
175
|
+
absences.push(`mcp config absent (${p})`);
|
|
176
|
+
continue;
|
|
177
|
+
}
|
|
178
|
+
const bytes = fs.readFileSync(p);
|
|
179
|
+
capture({
|
|
180
|
+
kind: 'mcp', id: label, name: `${label} MCP servers`, primary: `${label}.json`,
|
|
181
|
+
provenance: { harness: 'claude-code', native: p, ref: blobRef(bytes) },
|
|
182
|
+
projectionRules: { 'claude-code': '.mcp.json' },
|
|
183
|
+
}, [{ rel: `${label}.json`, bytes }]);
|
|
184
|
+
}
|
|
185
|
+
// ── plugins: registry snapshot (bundle capture = follow-up, stated) ────────
|
|
186
|
+
const pluginsReg = path.join(HOME, '.claude', 'plugins', 'installed_plugins.json');
|
|
187
|
+
if (fs.existsSync(pluginsReg)) {
|
|
188
|
+
const bytes = fs.readFileSync(pluginsReg);
|
|
189
|
+
capture({
|
|
190
|
+
kind: 'plugin', id: 'installed-registry', name: 'Installed plugins registry', primary: 'installed_plugins.json',
|
|
191
|
+
provenance: { harness: 'claude-code', native: pluginsReg, ref: blobRef(bytes) },
|
|
192
|
+
projectionRules: { 'claude-code': '.claude/plugins/installed_plugins.json' },
|
|
193
|
+
}, [{ rel: 'installed_plugins.json', bytes }]);
|
|
194
|
+
}
|
|
195
|
+
else
|
|
196
|
+
absences.push(`plugins registry absent (${pluginsReg})`);
|
|
197
|
+
// ── plans: doc-snapshot + thin state (fork 1 — never an event log) ─────────
|
|
198
|
+
const plansRoot = path.join(HOME, '.claude', 'plans');
|
|
199
|
+
let planFiles = [];
|
|
200
|
+
try {
|
|
201
|
+
planFiles = fs.readdirSync(plansRoot).filter((f) => f.endsWith('.md')).sort();
|
|
202
|
+
}
|
|
203
|
+
catch {
|
|
204
|
+
absences.push(`plans root absent (${plansRoot})`);
|
|
205
|
+
}
|
|
206
|
+
for (const f of planFiles) {
|
|
207
|
+
const abs = path.join(plansRoot, f);
|
|
208
|
+
const bytes = fs.readFileSync(abs);
|
|
209
|
+
const id = path.basename(f, '.md');
|
|
210
|
+
capture({
|
|
211
|
+
kind: 'plan', id, primary: f,
|
|
212
|
+
provenance: { harness: 'claude-code', native: abs, ref: blobRef(bytes) },
|
|
213
|
+
state: { status: 'snapshot', capturedFrom: 'claude-code-plans' },
|
|
214
|
+
}, [{ rel: f, bytes }]);
|
|
215
|
+
}
|
|
216
|
+
// ── projects: manifests for known roots (roots + per-harness session dirs) ─
|
|
217
|
+
const projects = [
|
|
218
|
+
['workspace', HOME],
|
|
219
|
+
['omniclaude-v4', path.join(HOME, 'omniclaude-v4')],
|
|
220
|
+
['nexus-terminal', path.join(HOME, 'nexus-terminal')],
|
|
221
|
+
];
|
|
222
|
+
for (const [id, root] of projects) {
|
|
223
|
+
if (!fs.existsSync(root))
|
|
224
|
+
continue;
|
|
225
|
+
const doc = JSON.stringify({
|
|
226
|
+
id, root,
|
|
227
|
+
sessionDirs: { 'nexus-cortex': path.join(root, '.cortex', 'sessions'), 'claude-code': `~/.claude/projects/${root.replace(/\//g, '-')}` },
|
|
228
|
+
}, null, 2) + '\n';
|
|
229
|
+
capture({
|
|
230
|
+
kind: 'project', id, primary: `${id}.json`,
|
|
231
|
+
provenance: { harness: 'workspace', native: root, ref: blobRef(doc) },
|
|
232
|
+
state: { status: 'active' },
|
|
233
|
+
}, [{ rel: `${id}.json`, bytes: Buffer.from(doc) }]);
|
|
234
|
+
}
|
|
235
|
+
// ── visibility doc + commit ────────────────────────────────────────────────
|
|
236
|
+
const summary = `${captured} captured, ${unchanged} unchanged (${Object.entries(kinds).map(([k, n]) => `${k}:${n}`).join(', ') || 'none'})`;
|
|
237
|
+
let pushed = false;
|
|
238
|
+
if (!DRY) {
|
|
239
|
+
const md = `# /canon/artifacts — ArtifactManifest records (§27p second record kind)\n\n` +
|
|
240
|
+
`One JSON manifest per artifact: identity, content-derived version (primary-file git\n` +
|
|
241
|
+
`blob ref), blob-addressed content listing, provenance, harnessCompat, projectionRules.\n` +
|
|
242
|
+
`Bytes live in the store taxonomy dirs (/skills /agents /mcp /plugins /plans /projects).\n\n` +
|
|
243
|
+
`## Not captured this run (visible, never silent — D8)\n` +
|
|
244
|
+
(absences.length ? absences.map((a) => `- ${a}\n`).join('') : '- none\n') +
|
|
245
|
+
`\n## Projection-back\nRendering artifacts INTO a receiving harness's layout (the pull side of the\n` +
|
|
246
|
+
`per-kind layout adapters) arrives with the artifact pull leg; until then its\nabsence is stated here rather than implied.\n`;
|
|
247
|
+
const mdPath = path.join(STORE, 'canon', 'artifacts', 'ARTIFACTS.md');
|
|
248
|
+
fs.mkdirSync(path.dirname(mdPath), { recursive: true });
|
|
249
|
+
fs.writeFileSync(mdPath, md);
|
|
250
|
+
fs.mkdirSync(path.dirname(MANIFEST_PATH), { recursive: true });
|
|
251
|
+
fs.writeFileSync(MANIFEST_PATH, JSON.stringify(incr));
|
|
252
|
+
const git = (a) => execFileSync('git', a, { cwd: STORE, encoding: 'utf8', env });
|
|
253
|
+
git(['add', '-A']);
|
|
254
|
+
if (git(['status', '--porcelain']).trim()) {
|
|
255
|
+
git(['commit', '-q', '-m', `canon-artifacts: ${summary}`]);
|
|
256
|
+
git(['push', '-q', 'origin', 'main']);
|
|
257
|
+
console.log(`[canon-artifacts] pushed: ${summary}`);
|
|
258
|
+
pushed = true;
|
|
259
|
+
}
|
|
260
|
+
else {
|
|
261
|
+
console.log(`[canon-artifacts] no changes (${summary})`);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
else {
|
|
265
|
+
console.log(`[canon-artifacts DRY] would capture ${captured}, unchanged ${unchanged}`);
|
|
266
|
+
}
|
|
267
|
+
return { captured, unchanged, kinds, pushed };
|
|
268
|
+
}
|
|
269
|
+
//# sourceMappingURL=canonArtifacts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonArtifacts.js","sourceRoot":"","sources":["../src/canonArtifacts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM,SAAS,CAAC;AAC9B,OAAO,KAAK,IAAI,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAiBlD,MAAM,eAAe,GAAuB;IAC1C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I,CAAC,OAAO,CAAC,aAAa,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC/D,EAAE,CAAC,aAAa,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC,CAAC;QACtD,MAAM,GAAG,GAAG,CAAC,CAAW,EAAE,EAAE,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,GAAG,EAAE,KAAK,EAAE,QAAQ,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;QAC3F,GAAG,CAAC,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC;QACnB,IAAI,GAAG,CAAC,CAAC,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;YAC1C,GAAG,CAAC,CAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,oBAAoB,OAAO,EAAE,CAAC,CAAC,CAAC;YAC3D,GAAG,CAAC,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;YACtC,OAAO,CAAC,GAAG,CAAC,6BAA6B,OAAO,EAAE,CAAC,CAAC;YACpD,MAAM,GAAG,IAAI,CAAC;QAChB,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,iCAAiC,OAAO,GAAG,CAAC,CAAC;QAC3D,CAAC;IACH,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,uCAAuC,QAAQ,eAAe,SAAS,EAAE,CAAC,CAAC;IACzF,CAAC;IACD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type CanonSession } from './canonPull.js';
|
|
2
|
+
export interface ProjectEntry {
|
|
3
|
+
id: string;
|
|
4
|
+
/** Best-effort decoded root (claude-code encoding is lossy on dashes — encoded form is authoritative). */
|
|
5
|
+
root: string;
|
|
6
|
+
/** Store-relative canon session dir prefixes per harness. */
|
|
7
|
+
sessionPaths: Record<string, string[]>;
|
|
8
|
+
sessionCounts: Record<string, number>;
|
|
9
|
+
}
|
|
10
|
+
/** Derive the authoritative project ↔ session-path map from store paths. */
|
|
11
|
+
export declare function deriveProjectSessionMap(store: string): Record<string, ProjectEntry>;
|
|
12
|
+
/** Resolve which project a canon session belongs to (by path prefix). */
|
|
13
|
+
export declare function sessionProject(projects: Record<string, ProjectEntry>, s: CanonSession): string | undefined;
|
|
14
|
+
export interface CanonGraphOptions {
|
|
15
|
+
store?: string;
|
|
16
|
+
/** Limit to one project id (default: all mapped projects). */
|
|
17
|
+
project?: string;
|
|
18
|
+
/** Path to an external (graphify) node-link graph.json to fold into each project graph. */
|
|
19
|
+
mergeGraph?: string;
|
|
20
|
+
dryRun?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface CanonGraphResult {
|
|
23
|
+
projects: string[];
|
|
24
|
+
nodes: number;
|
|
25
|
+
links: number;
|
|
26
|
+
pushed: boolean;
|
|
27
|
+
}
|
|
28
|
+
/** Generate /projects/<id>.json manifests + /projects/<id>/graph.json (node-link, 🔒 criteria). */
|
|
29
|
+
export declare function canonGraph(o?: CanonGraphOptions): Promise<CanonGraphResult>;
|
|
30
|
+
//# sourceMappingURL=canonGraph.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"canonGraph.d.ts","sourceRoot":"","sources":["../src/canonGraph.ts"],"names":[],"mappings":"AAgCA,OAAO,EAAyB,KAAK,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI1E,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,0GAA0G;IAC1G,IAAI,EAAE,MAAM,CAAC;IACb,6DAA6D;IAC7D,YAAY,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IACvC,aAAa,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACvC;AAcD,4EAA4E;AAC5E,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAiCnF;AAED,yEAAyE;AACzE,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,EAAE,CAAC,EAAE,YAAY,GAAG,MAAM,GAAG,SAAS,CAO1G;AAED,MAAM,WAAW,iBAAiB;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,8DAA8D;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,2FAA2F;IAC3F,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,mGAAmG;AACnG,wBAAsB,UAAU,CAAC,CAAC,GAAE,iBAAsB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAkGrF"}
|