@yaks/code 0.0.0-stage → 0.2.36
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/README.md +106 -2
- package/_dist/anatomy.d.ts +144 -0
- package/_dist/anatomy.d.ts.map +1 -0
- package/_dist/described.d.ts +31 -0
- package/_dist/described.d.ts.map +1 -0
- package/_dist/effects.d.ts +9 -0
- package/_dist/effects.d.ts.map +1 -0
- package/_dist/frames.d.ts +16 -0
- package/_dist/frames.d.ts.map +1 -0
- package/_dist/mod.d.ts +26 -0
- package/_dist/mod.d.ts.map +1 -0
- package/_dist/read.d.ts +89 -0
- package/_dist/read.d.ts.map +1 -0
- package/_dist/source.d.ts +55 -0
- package/_dist/source.d.ts.map +1 -0
- package/_dist/sync.d.ts +39 -0
- package/_dist/sync.d.ts.map +1 -0
- package/_dist/tools.d.ts +8 -0
- package/_dist/tools.d.ts.map +1 -0
- package/_dist/vocab.d.ts +6 -0
- package/_dist/vocab.d.ts.map +1 -0
- package/anatomy.js +552 -0
- package/anatomy.js.map +1 -0
- package/anatomy.ts +638 -0
- package/deno.json +1 -0
- package/described.js +274 -0
- package/described.js.map +1 -0
- package/described.ts +314 -0
- package/effects.js +24 -0
- package/effects.js.map +1 -0
- package/effects.ts +30 -0
- package/frames.js +46 -0
- package/frames.js.map +1 -0
- package/frames.ts +54 -0
- package/mod.js +26 -0
- package/mod.js.map +1 -0
- package/mod.ts +27 -0
- package/package.json +54 -4
- package/read.js +178 -0
- package/read.js.map +1 -0
- package/read.ts +249 -0
- package/source.js +238 -0
- package/source.js.map +1 -0
- package/source.ts +263 -0
- package/sync.js +345 -0
- package/sync.js.map +1 -0
- package/sync.ts +323 -0
- package/tools.js +49 -0
- package/tools.js.map +1 -0
- package/tools.ts +59 -0
- package/vocab.js +21 -0
- package/vocab.js.map +1 -0
- package/vocab.json +143 -0
- package/vocab.ts +22 -0
package/tools.js
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// The implementation behind `code sync` in ./vocab.json, exported as
|
|
2
|
+
// `@yaks/code/tools`.
|
|
3
|
+
//
|
|
4
|
+
// It reads the checkout at the calling process's `cwd` — on a command line the
|
|
5
|
+
// directory the command runs in — through @yaks/mirror, and writes what moved
|
|
6
|
+
// itself, in batches, as the caller. What it returns is only the report:
|
|
7
|
+
// handing a whole codebase back to the runner would make it the call's answer.
|
|
8
|
+
import { argsOf, who } from "@yaks/graph/call";
|
|
9
|
+
import { sync } from "@yaks/mirror";
|
|
10
|
+
import { CallError } from "@yaks/tools/errors";
|
|
11
|
+
import { codeMirror } from "./sync.js";
|
|
12
|
+
/** Sync the checkout at `cwd` into `g`, and say what it did in one line. */ export let codeSync = async (g, cwd, opts = {})=>{
|
|
13
|
+
if (!cwd) {
|
|
14
|
+
throw new CallError('cwd', 'code sync reads a checkout, and this runs in none');
|
|
15
|
+
}
|
|
16
|
+
let t = performance.now();
|
|
17
|
+
let { binding, said, root } = await codeMirror(g, cwd, opts);
|
|
18
|
+
let done = await sync(binding);
|
|
19
|
+
let ms = Math.round(performance.now() - t);
|
|
20
|
+
if (done.failed.length) {
|
|
21
|
+
throw new CallError('sync', done.failed.join('\n'));
|
|
22
|
+
}
|
|
23
|
+
let gone = done.read.length - said.modules;
|
|
24
|
+
return [
|
|
25
|
+
`${root}: read ${said.modules} files (${said.symbols} exports, ` + `${said.imports} imports, ${said.packages} packages)` + (gone ? `, cleared ${gone} gone` : '') + ` in ${ms} ms.`,
|
|
26
|
+
...said.refused.length ? [
|
|
27
|
+
`deno doc could not read the exports of: ${said.refused.join(', ')}`
|
|
28
|
+
] : []
|
|
29
|
+
].join('\n');
|
|
30
|
+
};
|
|
31
|
+
/** The implementations of the tools ./vocab.json declares. */ export let runs = ()=>({
|
|
32
|
+
code_sync: async (call, graph)=>[
|
|
33
|
+
{
|
|
34
|
+
entity: {
|
|
35
|
+
eid: '$synced'
|
|
36
|
+
},
|
|
37
|
+
content: {
|
|
38
|
+
body: await codeSync(graph, call.process?.cwd, {
|
|
39
|
+
full: argsOf(call).full == true,
|
|
40
|
+
actor: who(call)
|
|
41
|
+
})
|
|
42
|
+
},
|
|
43
|
+
output: {
|
|
44
|
+
source: call.entity.eid
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
]
|
|
48
|
+
});
|
|
49
|
+
//# sourceMappingURL=tools.js.map
|
package/tools.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tools.js","sources":["./tools.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,sBAAsB;AACtB,EAAE;AACF,+EAA+E;AAC/E,8EAA8E;AAC9E,yEAAyE;AACzE,+EAA+E;AAG/E,SAAS,MAAM,EAAE,GAAG,gCAAqC;AAEzD,SAAS,IAAI,4BAAiC;AAC9C,SAAS,SAAS,kCAAuC;AACzD,SAAS,UAAU,oBAAmB;AAEtC,0EAA0E,GAC1E,OAAO,IAAI,WAAW,OACpB,GACA,KACA,OAAiD,CAAC,CAAC;EAEnD,IAAI,CAAC,KAAK;IACR,MAAM,IAAI,UACR,OACA;EAEJ;EACA,IAAI,IAAI,YAAY,GAAG;EACvB,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,WAAW,GAAG,KAAK;EACvD,IAAI,OAAO,MAAM,KAAK;EACtB,IAAI,KAAK,KAAK,KAAK,CAAC,YAAY,GAAG,KAAK;EACxC,IAAI,KAAK,MAAM,CAAC,MAAM,EAAE;IACtB,MAAM,IAAI,UAAU,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC;EAC/C;EACA,IAAI,OAAO,KAAK,IAAI,CAAC,MAAM,GAAG,KAAK,OAAO;EAC1C,OAAO;IACL,GAAG,KAAK,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,KAAK,OAAO,CAAC,UAAU,CAAC,GAChE,GAAG,KAAK,OAAO,CAAC,UAAU,EAAE,KAAK,QAAQ,CAAC,UAAU,CAAC,GACrD,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,KAAK,CAAC,GAAG,EAAE,IAAI,CAAC,IAAI,EAAE,GAAG,IAAI,CAAC;OACrD,KAAK,OAAO,CAAC,MAAM,GAClB;MAAC,CAAC,wCAAwC,EAAE,KAAK,OAAO,CAAC,IAAI,CAAC,OAAO;KAAC,GACtE,EAAE;GACP,CAAC,IAAI,CAAC;AACT,EAAC;AAED,4DAA4D,GAC5D,OAAO,IAAI,OAAO,IAAY,CAAC;IAC7B,WAAW,OAAO,MAAM,QAA6B;QAAC;UACpD,QAAQ;YAAE,KAAK;UAAU;UACzB,SAAS;YACP,MAAM,MAAM,SACV,OACC,KAAK,OAAO,EAAuB,KACpC;cAAE,MAAM,OAAO,MAAM,IAAI,IAAI;cAAM,OAAO,IAAI;YAAM;UAExD;UACA,QAAQ;YAAE,QAAQ,KAAK,MAAM,CAAC,GAAG;UAAC;QACpC;OAAE;EACJ,CAAC,EAAC"}
|
package/tools.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
// The implementation behind `code sync` in ./vocab.json, exported as
|
|
2
|
+
// `@yaks/code/tools`.
|
|
3
|
+
//
|
|
4
|
+
// It reads the checkout at the calling process's `cwd` — on a command line the
|
|
5
|
+
// directory the command runs in — through @yaks/mirror, and writes what moved
|
|
6
|
+
// itself, in batches, as the caller. What it returns is only the report:
|
|
7
|
+
// handing a whole codebase back to the runner would make it the call's answer.
|
|
8
|
+
|
|
9
|
+
import type { Actor, Bundle, Comp, Graph } from 'jsr:@yaks/graph@0.2.36'
|
|
10
|
+
import { argsOf, who } from '@yaks/graph/call'
|
|
11
|
+
import type { Runs } from 'jsr:@yaks/graph@0.2.36/tools'
|
|
12
|
+
import { sync } from '@yaks/mirror'
|
|
13
|
+
import { CallError } from '@yaks/tools/errors'
|
|
14
|
+
import { codeMirror } from './sync.js'
|
|
15
|
+
|
|
16
|
+
/** Sync the checkout at `cwd` into `g`, and say what it did in one line. */
|
|
17
|
+
export let codeSync = async (
|
|
18
|
+
g: Graph,
|
|
19
|
+
cwd: string | undefined,
|
|
20
|
+
opts: { full?: boolean; actor?: Actor | null } = {},
|
|
21
|
+
): Promise<string> => {
|
|
22
|
+
if (!cwd) {
|
|
23
|
+
throw new CallError(
|
|
24
|
+
'cwd',
|
|
25
|
+
'code sync reads a checkout, and this runs in none',
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
let t = performance.now()
|
|
29
|
+
let { binding, said, root } = await codeMirror(g, cwd, opts)
|
|
30
|
+
let done = await sync(binding)
|
|
31
|
+
let ms = Math.round(performance.now() - t)
|
|
32
|
+
if (done.failed.length) {
|
|
33
|
+
throw new CallError('sync', done.failed.join('\n'))
|
|
34
|
+
}
|
|
35
|
+
let gone = done.read.length - said.modules
|
|
36
|
+
return [
|
|
37
|
+
`${root}: read ${said.modules} files (${said.symbols} exports, ` +
|
|
38
|
+
`${said.imports} imports, ${said.packages} packages)` +
|
|
39
|
+
(gone ? `, cleared ${gone} gone` : '') + ` in ${ms} ms.`,
|
|
40
|
+
...said.refused.length
|
|
41
|
+
? [`deno doc could not read the exports of: ${said.refused.join(', ')}`]
|
|
42
|
+
: [],
|
|
43
|
+
].join('\n')
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** The implementations of the tools ./vocab.json declares. */
|
|
47
|
+
export let runs = (): Runs => ({
|
|
48
|
+
code_sync: async (call, graph): Promise<Bundle[]> => [{
|
|
49
|
+
entity: { eid: '$synced' },
|
|
50
|
+
content: {
|
|
51
|
+
body: await codeSync(
|
|
52
|
+
graph,
|
|
53
|
+
(call.process as Comp | undefined)?.cwd as string | undefined,
|
|
54
|
+
{ full: argsOf(call).full == true, actor: who(call) },
|
|
55
|
+
),
|
|
56
|
+
},
|
|
57
|
+
output: { source: call.entity.eid },
|
|
58
|
+
}],
|
|
59
|
+
})
|
package/vocab.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The component declarations, and nothing else: the module a server or a
|
|
2
|
+
// browser page imports at `@yaks/code/vocab`. It reaches no storage and runs
|
|
3
|
+
// no subprocess.
|
|
4
|
+
//
|
|
5
|
+
// A module is identified by the `file{path, root}` it wears, which @yaks/file
|
|
6
|
+
// declares, rooted in a @yaks/git `repository`, so a graph loading this
|
|
7
|
+
// document loads @yaks/file's and @yaks/git's beside it, and @yaks/edge's for
|
|
8
|
+
// the `imports` relation.
|
|
9
|
+
import doc from './vocab.json' with {
|
|
10
|
+
type: 'json'
|
|
11
|
+
};
|
|
12
|
+
import manifest from './package.json' with {
|
|
13
|
+
type: 'json'
|
|
14
|
+
};
|
|
15
|
+
/** `package`, `module`, `symbol`, the `imports` relation and `code sync`. */ export let codeDoc = doc;
|
|
16
|
+
/** What this package is: its manifest's description, the one place it is
|
|
17
|
+
* written, which a host stamps on each document here. */ export let description = manifest.description;
|
|
18
|
+
/** Every document this plugin declares. */ export let docs = [
|
|
19
|
+
codeDoc
|
|
20
|
+
];
|
|
21
|
+
//# sourceMappingURL=vocab.js.map
|
package/vocab.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vocab.js","sources":["./vocab.ts"],"names":[],"mappings":"AAAA,yEAAyE;AACzE,6EAA6E;AAC7E,iBAAiB;AACjB,EAAE;AACF,8EAA8E;AAC9E,wEAAwE;AACxE,8EAA8E;AAC9E,0BAA0B;AAG1B,OAAO,SAAS,oBAAoB;EAAE,MAAM;AAAO,EAAC;AACpD,OAAO,cAAc,sBAAsB;EAAE,MAAM;AAAO,EAAC;AAE3D,2EAA2E,GAC3E,OAAO,IAAI,UAAoB,IAAG;AAElC;uDACuD,GACvD,OAAO,IAAI,cAAsB,SAAS,WAAW,CAAA;AAErD,yCAAyC,GACzC,OAAO,IAAI,OAAmB;EAAC;CAAQ,CAAA"}
|
package/vocab.json
ADDED
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$id": "urn:uuid:47d95c29-9269-48b4-aaa6-2325f7eaf425",
|
|
3
|
+
"$vocabulary": {
|
|
4
|
+
"https://yak.sh/vocab/core": true,
|
|
5
|
+
"https://yak.sh/vocab/edge": true
|
|
6
|
+
},
|
|
7
|
+
"title": "code",
|
|
8
|
+
"$defs": {
|
|
9
|
+
"package": {
|
|
10
|
+
"$id": "urn:uuid:4e7f534f-1d9b-4173-b34f-28004ae3d78b",
|
|
11
|
+
"component": true,
|
|
12
|
+
"journal": false,
|
|
13
|
+
"type": "object",
|
|
14
|
+
"description": "a package, read from its manifest; its entity id is derived from its name, so every checkout of it is one entity",
|
|
15
|
+
"properties": {
|
|
16
|
+
"name": {
|
|
17
|
+
"$id": "urn:uuid:d4d38f68-b443-42d3-80e8-f3889a449e45",
|
|
18
|
+
"type": "string",
|
|
19
|
+
"identity": true,
|
|
20
|
+
"description": "the name its manifest publishes it under"
|
|
21
|
+
},
|
|
22
|
+
"version": {
|
|
23
|
+
"$id": "urn:uuid:99f506f9-5e2c-4892-88cd-324fbedf7582",
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "the version its manifest says"
|
|
26
|
+
},
|
|
27
|
+
"manifest": {
|
|
28
|
+
"$id": "urn:uuid:e35b811f-9024-4d4a-91ed-de5aa17fdb3e",
|
|
29
|
+
"type": "string",
|
|
30
|
+
"ref": "entity",
|
|
31
|
+
"death": "detach",
|
|
32
|
+
"description": "the module the package was read from: its package.json"
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
"module": {
|
|
37
|
+
"$id": "urn:uuid:0aa20cd5-74ee-4807-9fa6-4d4b740346d0",
|
|
38
|
+
"component": true,
|
|
39
|
+
"journal": false,
|
|
40
|
+
"type": "object",
|
|
41
|
+
"description": "one file of a codebase, read from the file itself; it wears the `file` it was read from, which identifies it, and its `doc` is its opening paragraph",
|
|
42
|
+
"properties": {
|
|
43
|
+
"blob": {
|
|
44
|
+
"$id": "urn:uuid:30375da0-4467-4ebc-933f-a3451b29ace2",
|
|
45
|
+
"type": "string",
|
|
46
|
+
"description": "the Git blob id of the text it was read from; a sync reads the file again only when this moved"
|
|
47
|
+
},
|
|
48
|
+
"package": {
|
|
49
|
+
"$id": "urn:uuid:e5f016eb-0e75-4c6e-8f44-37b9b56aded0",
|
|
50
|
+
"type": "string",
|
|
51
|
+
"ref": "entity",
|
|
52
|
+
"death": "detach",
|
|
53
|
+
"description": "the package the file belongs to: the nearest manifest above it"
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"symbol": {
|
|
58
|
+
"$id": "urn:uuid:e5d62994-2376-4509-aa48-920ce0bb4d19",
|
|
59
|
+
"component": true,
|
|
60
|
+
"journal": false,
|
|
61
|
+
"type": "object",
|
|
62
|
+
"identity": ["module", "name"],
|
|
63
|
+
"description": "a definition a module exports; identified by the module and its name, so a citation of it survives the file moving around it. Its `doc` is its doc comment",
|
|
64
|
+
"properties": {
|
|
65
|
+
"module": {
|
|
66
|
+
"$id": "urn:uuid:c406e0e7-60a4-4400-a7aa-b583a8be2e0e",
|
|
67
|
+
"type": "string",
|
|
68
|
+
"ref": "entity",
|
|
69
|
+
"death": "cascade",
|
|
70
|
+
"description": "the module that exports it"
|
|
71
|
+
},
|
|
72
|
+
"name": {
|
|
73
|
+
"$id": "urn:uuid:45f53b01-4481-44ea-9dbe-f8d09b647769",
|
|
74
|
+
"type": "string",
|
|
75
|
+
"description": "the name it is exported under"
|
|
76
|
+
},
|
|
77
|
+
"kind": {
|
|
78
|
+
"$id": "urn:uuid:578023a1-10ec-4547-b8fa-3fc3f4d70eb7",
|
|
79
|
+
"type": "string",
|
|
80
|
+
"description": "what it is, as `deno doc` says: function, variable, class, interface, typeAlias, enum or namespace"
|
|
81
|
+
},
|
|
82
|
+
"line": {
|
|
83
|
+
"$id": "urn:uuid:f9f4d474-bdf1-4e37-9526-db1c29d00591",
|
|
84
|
+
"type": "number",
|
|
85
|
+
"description": "the line it is declared on, counting from 1"
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"imports": {
|
|
90
|
+
"$id": "urn:uuid:dbcc052a-76e0-4ae3-8590-04a32a38374f",
|
|
91
|
+
"component": true,
|
|
92
|
+
"journal": false,
|
|
93
|
+
"type": "object",
|
|
94
|
+
"edge": true,
|
|
95
|
+
"reversed": "imported by",
|
|
96
|
+
"description": "edge tag: this module imports or re-exports that one",
|
|
97
|
+
"properties": {}
|
|
98
|
+
},
|
|
99
|
+
"code_sync": {
|
|
100
|
+
"tool": true,
|
|
101
|
+
"destructive": false,
|
|
102
|
+
"noun": "code",
|
|
103
|
+
"verb": "sync",
|
|
104
|
+
"title": "Sync the codebase",
|
|
105
|
+
"description": "Read the codebase of the checkout this call runs in into the graph: a package per manifest, a module per TypeScript, JavaScript or Markdown file Git tracks, a symbol per export, and an `imports` link per import. Only files whose Git blob moved since the last sync are read again; a file that is gone has its module and symbols cleared, never deleted, so a path or name that comes back is the same entity. Returns a one-paragraph report of what it read, cleared and how long it took.",
|
|
106
|
+
"input": {
|
|
107
|
+
"full": {
|
|
108
|
+
"type": "boolean",
|
|
109
|
+
"description": "read every file, not only the ones that moved"
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"vocab_describe": {
|
|
114
|
+
"effect": true,
|
|
115
|
+
"start": true,
|
|
116
|
+
"description": "describe the vocabulary this graph is served with as @yaks/vocab's _namespace, _comp, _effect, _extends, _prop and _before entities whenever a process starts working the effects, clearing what it no longer declares; a graph already describing it is checked by the hash its _vocab holds and written nothing"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"kinds": {
|
|
120
|
+
"package": {
|
|
121
|
+
"$id": "urn:uuid:4e7f534f-1d9b-4173-b34f-28004ae3d78b",
|
|
122
|
+
"description": "a package, read from its manifest; its entity id is derived from its name, so every checkout of it is one entity",
|
|
123
|
+
"with": {
|
|
124
|
+
"doc": true
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"module": {
|
|
128
|
+
"$id": "urn:uuid:0aa20cd5-74ee-4807-9fa6-4d4b740346d0",
|
|
129
|
+
"description": "one file of a codebase, read from the file itself; it wears the `file` it was read from, which identifies it, and its `doc` is its opening paragraph",
|
|
130
|
+
"with": {
|
|
131
|
+
"doc": true,
|
|
132
|
+
"file": true
|
|
133
|
+
}
|
|
134
|
+
},
|
|
135
|
+
"symbol": {
|
|
136
|
+
"$id": "urn:uuid:e5d62994-2376-4509-aa48-920ce0bb4d19",
|
|
137
|
+
"description": "a definition a module exports; identified by the module and its name, so a citation of it survives the file moving around it. Its `doc` is its doc comment",
|
|
138
|
+
"with": {
|
|
139
|
+
"doc": true
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
package/vocab.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// The component declarations, and nothing else: the module a server or a
|
|
2
|
+
// browser page imports at `@yaks/code/vocab`. It reaches no storage and runs
|
|
3
|
+
// no subprocess.
|
|
4
|
+
//
|
|
5
|
+
// A module is identified by the `file{path, root}` it wears, which @yaks/file
|
|
6
|
+
// declares, rooted in a @yaks/git `repository`, so a graph loading this
|
|
7
|
+
// document loads @yaks/file's and @yaks/git's beside it, and @yaks/edge's for
|
|
8
|
+
// the `imports` relation.
|
|
9
|
+
|
|
10
|
+
import type { VocabDoc } from 'jsr:@yaks/vocab@0.2.36'
|
|
11
|
+
import doc from './vocab.json' with { type: 'json' }
|
|
12
|
+
import manifest from './package.json' with { type: 'json' }
|
|
13
|
+
|
|
14
|
+
/** `package`, `module`, `symbol`, the `imports` relation and `code sync`. */
|
|
15
|
+
export let codeDoc: VocabDoc = doc
|
|
16
|
+
|
|
17
|
+
/** What this package is: its manifest's description, the one place it is
|
|
18
|
+
* written, which a host stamps on each document here. */
|
|
19
|
+
export let description: string = manifest.description
|
|
20
|
+
|
|
21
|
+
/** Every document this plugin declares. */
|
|
22
|
+
export let docs: VocabDoc[] = [codeDoc]
|