@voxgig/sdkgen 3.0.0 → 3.2.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.
Files changed (45) hide show
  1. package/dist/action/doctor.js +65 -10
  2. package/dist/action/doctor.js.map +1 -1
  3. package/dist/cmp/ExternalTarget.d.ts +2 -0
  4. package/dist/cmp/ExternalTarget.js +104 -0
  5. package/dist/cmp/ExternalTarget.js.map +1 -0
  6. package/dist/helpers/packageMeta.d.ts +9 -1
  7. package/dist/helpers/packageMeta.js +54 -0
  8. package/dist/helpers/packageMeta.js.map +1 -1
  9. package/dist/sdkgen.d.ts +2 -2
  10. package/dist/sdkgen.js +229 -2
  11. package/dist/sdkgen.js.map +1 -1
  12. package/dist/tsconfig.tsbuildinfo +1 -1
  13. package/dist/types.d.ts +12 -0
  14. package/dist/utility.js +10 -1
  15. package/dist/utility.js.map +1 -1
  16. package/model/sdkgen.aontu +130 -0
  17. package/package.json +1 -1
  18. package/project/.sdk/model/target/go-cli.aontu +0 -1
  19. package/project/.sdk/model/target/go-mcp.aontu +0 -1
  20. package/project/.sdk/model/target/java.aontu +0 -1
  21. package/project/.sdk/model/target/kotlin.aontu +0 -1
  22. package/project/.sdk/model/target/lean.aontu +0 -1
  23. package/project/.sdk/model/target/py-data.aontu +0 -1
  24. package/project/.sdk/model/target/scala.aontu +0 -1
  25. package/project/.sdk/model/target/seneca-provider.aontu +118 -0
  26. package/project/.sdk/model/target/zig.aontu +0 -1
  27. package/project/.sdk/src/cmp/js/Package_js.ts +8 -1
  28. package/project/.sdk/src/cmp/ocaml/Package_ocaml.ts +9 -2
  29. package/project/.sdk/src/cmp/php/Package_php.ts +9 -2
  30. package/project/.sdk/src/cmp/rb/Package_rb.ts +9 -2
  31. package/project/.sdk/src/cmp/seneca-provider/Extras_seneca-provider.ts +3915 -0
  32. package/project/.sdk/src/cmp/seneca-provider/Main_seneca-provider.ts +960 -0
  33. package/project/.sdk/src/cmp/ts/Package_ts.ts +8 -1
  34. package/project/.sdk/tm/seneca-provider/CODE_OF_CONDUCT.md +132 -0
  35. package/project/.sdk/tm/seneca-provider/LICENSE +21 -0
  36. package/project/.sdk/tm/seneca-provider/Makefile +15 -0
  37. package/project/.sdk/tm/seneca-provider/src/tsconfig.json +18 -0
  38. package/project/.sdk/tm/seneca-provider/test/tsconfig.json +16 -0
  39. package/project/.sdk/tm/seneca-provider/tsfmt.json +3 -0
  40. package/src/action/doctor.ts +77 -12
  41. package/src/cmp/ExternalTarget.ts +125 -0
  42. package/src/helpers/packageMeta.ts +63 -0
  43. package/src/sdkgen.ts +280 -1
  44. package/src/types.ts +24 -1
  45. package/src/utility.ts +10 -1
@@ -12,6 +12,7 @@ import {
12
12
  PUBLISHER,
13
13
  PUBLISHER_URL,
14
14
  packageVersion,
15
+ authorInfo,
15
16
  } from '@voxgig/sdkgen'
16
17
 
17
18
 
@@ -29,6 +30,12 @@ const Package = cmp(async function Package(props: any) {
29
30
 
30
31
  const model: Model = ctx$.model
31
32
 
33
+ // WHO WROTE THIS PACKAGE. Per target, falling back to the model-wide value
34
+ // and then to the publisher — so a manifest cannot go on naming Voxgig
35
+ // while the model names someone else, which is exactly what the hardcoded
36
+ // constant here did.
37
+ const author = authorInfo(model, target.name)
38
+
32
39
  const feature = getModelPath(model, `main.${KIT}.feature`)
33
40
 
34
41
  const only = (kind: string, deps: any) =>
@@ -106,7 +113,7 @@ const Package = cmp(async function Package(props: any) {
106
113
  "clean": "rm -rf node_modules yarn.lock package-lock.json dist dist-test",
107
114
  "reset": "npm run clean && npm i && npm run build && npm test",
108
115
  },
109
- author: { name: PUBLISHER, url: PUBLISHER_URL },
116
+ author,
110
117
 
111
118
  // TODO: needs to be config
112
119
  license: 'MIT',
@@ -0,0 +1,132 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of age, body
7
+ size, visible or invisible disability, ethnicity, sex characteristics, gender
8
+ identity and expression, level of experience, education, socio-economic status,
9
+ nationality, personal appearance, race, caste, color, religion, or sexual
10
+ identity and orientation.
11
+
12
+ We pledge to act and interact in ways that contribute to an open, welcoming,
13
+ diverse, inclusive, and healthy community.
14
+
15
+ ## Our Standards
16
+
17
+ Examples of behavior that contributes to a positive environment for our
18
+ community include:
19
+
20
+ - Demonstrating empathy and kindness toward other people
21
+ - Being respectful of differing opinions, viewpoints, and experiences
22
+ - Giving and gracefully accepting constructive feedback
23
+ - Accepting responsibility and apologizing to those affected by our mistakes,
24
+ and learning from the experience
25
+ - Focusing on what is best not just for us as individuals, but for the overall
26
+ community
27
+
28
+ Examples of unacceptable behavior include:
29
+
30
+ - The use of sexualized language or imagery, and sexual attention or advances of
31
+ any kind
32
+ - Trolling, insulting or derogatory comments, and personal or political attacks
33
+ - Public or private harassment
34
+ - Publishing others' private information, such as a physical or email address,
35
+ without their explicit permission
36
+ - Other conduct which could reasonably be considered inappropriate in a
37
+ professional setting
38
+
39
+ ## Enforcement Responsibilities
40
+
41
+ Community leaders are responsible for clarifying and enforcing our standards of
42
+ acceptable behavior and will take appropriate and fair corrective action in
43
+ response to any behavior that they deem inappropriate, threatening, offensive,
44
+ or harmful.
45
+
46
+ Community leaders have the right and responsibility to remove, edit, or reject
47
+ comments, commits, code, wiki edits, issues, and other contributions that are
48
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
49
+ decisions when appropriate.
50
+
51
+ ## Scope
52
+
53
+ This Code of Conduct applies within all community spaces, and also applies when
54
+ an individual is officially representing the community in public spaces.
55
+ Examples of representing our community include using an official e-mail address,
56
+ posting via an official social media account, or acting as an appointed
57
+ representative at an online or offline event.
58
+
59
+ ## Enforcement
60
+
61
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
62
+ reported to the community leaders responsible for enforcement at
63
+ [INSERT CONTACT METHOD].
64
+ All complaints will be reviewed and investigated promptly and fairly.
65
+
66
+ All community leaders are obligated to respect the privacy and security of the
67
+ reporter of any incident.
68
+
69
+ ## Enforcement Guidelines
70
+
71
+ Community leaders will follow these Community Impact Guidelines in determining
72
+ the consequences for any action they deem in violation of this Code of Conduct:
73
+
74
+ ### 1. Correction
75
+
76
+ **Community Impact**: Use of inappropriate language or other behavior deemed
77
+ unprofessional or unwelcome in the community.
78
+
79
+ **Consequence**: A private, written warning from community leaders, providing
80
+ clarity around the nature of the violation and an explanation of why the
81
+ behavior was inappropriate. A public apology may be requested.
82
+
83
+ ### 2. Warning
84
+
85
+ **Community Impact**: A violation through a single incident or series of
86
+ actions.
87
+
88
+ **Consequence**: A warning with consequences for continued behavior. No
89
+ interaction with the people involved, including unsolicited interaction with
90
+ those enforcing the Code of Conduct, for a specified period of time. This
91
+ includes avoiding interactions in community spaces as well as external channels
92
+ like social media. Violating these terms may lead to a temporary or permanent
93
+ ban.
94
+
95
+ ### 3. Temporary Ban
96
+
97
+ **Community Impact**: A serious violation of community standards, including
98
+ sustained inappropriate behavior.
99
+
100
+ **Consequence**: A temporary ban from any sort of interaction or public
101
+ communication with the community for a specified period of time. No public or
102
+ private interaction with the people involved, including unsolicited interaction
103
+ with those enforcing the Code of Conduct, is allowed during this period.
104
+ Violating these terms may lead to a permanent ban.
105
+
106
+ ### 4. Permanent Ban
107
+
108
+ **Community Impact**: Demonstrating a pattern of violation of community
109
+ standards, including sustained inappropriate behavior, harassment of an
110
+ individual, or aggression toward or disparagement of classes of individuals.
111
+
112
+ **Consequence**: A permanent ban from any sort of public interaction within the
113
+ community.
114
+
115
+ ## Attribution
116
+
117
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
118
+ version 2.1, available at
119
+ [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
120
+
121
+ Community Impact Guidelines were inspired by
122
+ [Mozilla's code of conduct enforcement ladder][mozilla coc].
123
+
124
+ For answers to common questions about this code of conduct, see the FAQ at
125
+ [https://www.contributor-covenant.org/faq][faq]. Translations are available at
126
+ [https://www.contributor-covenant.org/translations][translations].
127
+
128
+ [homepage]: https://www.contributor-covenant.org
129
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
130
+ [mozilla coc]: https://github.com/mozilla/diversity
131
+ [faq]: https://www.contributor-covenant.org/faq
132
+ [translations]: https://www.contributor-covenant.org/translations
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Seneca Microservices Framework
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,15 @@
1
+ .PHONY: all build test clean reset
2
+
3
+ all: build test
4
+
5
+ build:
6
+ npm run build
7
+
8
+ test:
9
+ npm test
10
+
11
+ clean:
12
+ rm -rf dist dist-test .tsbuildinfo
13
+
14
+ reset:
15
+ npm run reset
@@ -0,0 +1,18 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "module": "nodenext",
5
+ "noEmitOnError": true,
6
+ "outDir": "../dist",
7
+ "rootDir": ".",
8
+ "tsBuildInfoFile": "../.tsbuildinfo/src.json",
9
+ "resolveJsonModule": true,
10
+ "sourceMap": true,
11
+ "strict": true,
12
+ "target": "es2022",
13
+ "useDefineForClassFields": false,
14
+ "declaration": true,
15
+ "declarationDir": "../dist",
16
+ "types": ["node"]
17
+ }
18
+ }
@@ -0,0 +1,16 @@
1
+ {
2
+ "compilerOptions": {
3
+ "esModuleInterop": true,
4
+ "module": "nodenext",
5
+ "noEmitOnError": true,
6
+ "outDir": "../dist-test",
7
+ "rootDir": ".",
8
+ "tsBuildInfoFile": "../.tsbuildinfo/test.json",
9
+ "resolveJsonModule": true,
10
+ "sourceMap": true,
11
+ "strict": true,
12
+ "target": "es2022",
13
+ "types": ["node"]
14
+ },
15
+ "include": ["**/*.ts"]
16
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "indentSize": 2
3
+ }
@@ -4,13 +4,13 @@
4
4
  // WHY THIS EXISTS
5
5
  //
6
6
  // Nothing told a project that its `.sdk/` had drifted. `target add`
7
- // OVERWRITES the vendored components and template masters, so any hand-edit
8
- // there is silently reverted on the next run — and any file the scaffold has
9
- // since stopped shipping just stays, compiling into the output forever. In
10
- // voxgig-solardemo-sdk two such orphans broke the Go build in a single
11
- // session: `utility/make_target.go` (replaced upstream by `make_point.go`,
12
- // leaving a duplicate symbol) and `utility/struct/go.mod` (a nested module
13
- // that made `utility/struct` unimportable).
7
+ // OVERWRITES the vendored components, the template masters AND the per-target
8
+ // model file, so any hand-edit there is silently reverted on the next run —
9
+ // and any file the scaffold has since stopped shipping just stays, compiling
10
+ // into the output forever. In voxgig-solardemo-sdk two such orphans broke the
11
+ // Go build in a single session: `utility/make_target.go` (replaced upstream by
12
+ // `make_point.go`, leaving a duplicate symbol) and `utility/struct/go.mod` (a
13
+ // nested module that made `utility/struct` unimportable).
14
14
  //
15
15
  // Every divergence in that repo was found by hand-diffing. Without a check,
16
16
  // fixing it once guarantees nothing about next month.
@@ -84,8 +84,9 @@ const ROOT_COMPONENTS: [string, string][] = [
84
84
  // What the check found, by category. Categories 1-3 are drift; `additive` is
85
85
  // the project's own work and is reported separately, never as a problem.
86
86
  type DoctorReport = {
87
- // `.sdk/src/cmp/**` that differs from the scaffold. `target add` will
88
- // silently revert every one of these.
87
+ // `.sdk/src/cmp/**`, or a target's own `.sdk/model/target/<t>.aontu`, that
88
+ // differs from the scaffold. `target add` will silently revert every one of
89
+ // these.
89
90
  forked: string[]
90
91
 
91
92
  // `.sdk/tm/**` that differs from the scaffold AFTER the same substitution
@@ -252,7 +253,8 @@ function checkTarget(actx: ActionContext, resolved: any, report: DoctorReport) {
252
253
  const model = actx.model
253
254
  const root = actx.folder
254
255
 
255
- // The two trees `target add` owns, and the substitution it applies to each.
256
+ // The two TREES `target add` owns, and the substitution it applies to each.
257
+ // (It owns one FILE as well — see checkTargetModel, below.)
256
258
  //
257
259
  // src/cmp — copied verbatim, so a byte compare is the truth.
258
260
  // tm — copied through jostraca's template(), with ProjectName.
@@ -329,6 +331,60 @@ function checkTarget(actx: ActionContext, resolved: any, report: DoctorReport) {
329
331
  }
330
332
  }
331
333
  }
334
+
335
+ checkTargetModel(actx, resolved, report)
336
+ }
337
+
338
+
339
+ // The THIRD thing `target add` writes for a target, and the one nothing
340
+ // compared: `model/target/<t>.aontu` (src/action/target.ts, the Copy with the
341
+ // `'BASE'` replacement).
342
+ //
343
+ // It is not scaffolding trivia. That file carries the target's dependency
344
+ // set, its `phase` gates, `srcfeature`, `feature.trim` / `feature.fullset`
345
+ // and its publish-registry identity — and `target add` OVERWRITES it exactly
346
+ // as it overwrites src/cmp and tm. So a maintainer who fixes a dep version
347
+ // there loses the fix on the next resync with nothing said (the SDK regresses
348
+ // with nobody touching it, which is the failure the "a project decision
349
+ // belongs in the MODEL" rule exists to prevent), and a project whose copy
350
+ // predates a scaffold change carries the old declaration forever while doctor
351
+ // reported the target in sync. Both are the drift this command exists to
352
+ // name; the file was simply in neither tree it walked.
353
+ function checkTargetModel(actx: ActionContext, resolved: any, report: DoctorReport) {
354
+ const { tname, tfolder, torigname, base } = resolved
355
+ const fs = actx.fs()
356
+
357
+ const scaffold = Path.join(tfolder, 'model', 'target', torigname + '.aontu')
358
+
359
+ // No scaffold file means nothing to compare against, which is the ALIASED
360
+ // target: `target add go~go2` copies go.aontu to model/target/go2.aontu and
361
+ // docs/how-to/add-a-target.md then tells the project to EDIT it (a second Go
362
+ // module needs its own module name and deps). doctor resolves a target by
363
+ // its INSTALLED name — the model records `base`, not the ref it came from —
364
+ // so the origin is not recoverable here, and reporting that documented edit
365
+ // as drift on every run is worse than saying nothing.
366
+ if (!fs.existsSync(scaffold)) {
367
+ return
368
+ }
369
+
370
+ const project = Path.join(actx.folder, 'model', 'target', tname + '.aontu')
371
+ const label = 'model/target/' + tname + '.aontu'
372
+
373
+ if (!fs.existsSync(project)) {
374
+ report.missing.push(label)
375
+ return
376
+ }
377
+
378
+ // The substitution `target add` applied on the way in: jostraca's template()
379
+ // against the model (so `module: name: '$$name$$'` arrives as the project
380
+ // slug) plus the `'BASE'` replacement recording where the scaffold was.
381
+ //
382
+ // NOT templateReplacements() — that is the tm/ tree's map. The two writers
383
+ // pass different maps, so doctor has to as well, or every csharp/swift/ts
384
+ // project reads as forked on the `base:` line alone.
385
+ if (differs(fs, scaffold, project, actx.model, { "'BASE'": "'" + base + "'" })) {
386
+ report.forked.push(label)
387
+ }
332
388
  }
333
389
 
334
390
 
@@ -384,8 +440,17 @@ function differs(
384
440
  }
385
441
 
386
442
  const src = fs.readFileSync(scaffoldPath, 'utf8')
387
- const expected = 0 === Object.keys(replace).length ? src :
388
- template(src, model, { replace })
443
+
444
+ // template() runs even when there is nothing to REPLACE, because jostraca's
445
+ // Copy always interpolates `$$ref$$` against the model as well — the replace
446
+ // map is an extra, not the whole substitution. Skipping it for the src/cmp
447
+ // tree (whose Copy passes no replace map) meant the three Config fragments
448
+ // that carry `$$const.Name$$` / `$$main.kit.info.servers.0.url$$` arrived
449
+ // substituted and compared as bytes: every project with ts, js or dart
450
+ // reported `src/cmp/<t>/fragment/Config.fragment.<ext>` as FORKED straight
451
+ // out of `target add`, which is precisely the noise this function exists to
452
+ // remove. With no `$$` refs and no replace keys, template() is the identity.
453
+ const expected = template(src, model, { replace })
389
454
 
390
455
  return expected !== fs.readFileSync(projectPath, 'utf8')
391
456
  }
@@ -0,0 +1,125 @@
1
+ // The Root for a target that generates OUTSIDE the SDK repo
2
+ // (`main: kit: target: <t>: output: path`).
3
+ //
4
+ // WHY THIS EXISTS, rather than a folder name
5
+ //
6
+ // A target's files normally land in `<sdk-repo>/<target>/`, which the
7
+ // consumer's own `Root.ts` arranges with `Folder({ name: target.name })`.
8
+ // Two things stop that reaching a sibling repo:
9
+ //
10
+ // - jostraca REFUSES a `..` segment in a Folder name (FileHandler.validName
11
+ // throws). Escaping the output root through a folder name is not an
12
+ // oversight to work around; it is the guard that keeps generation inside
13
+ // the tree it was pointed at.
14
+ // - the output root is `jopts.folder`, per generate() CALL. So writing
15
+ // somewhere else means another call, not another folder.
16
+ //
17
+ // So an out-of-tree target gets its own generate() pass, rooted at its
18
+ // output path, with this as the Root. It renders ONE target and nothing
19
+ // else: the consumer Root also emits the SDK repo's own furniture (its
20
+ // README, AGENTS.md, the build scaffold), and none of that belongs in a
21
+ // separate package's repo.
22
+ //
23
+ // No Folder wraps the target here — the destination IS the package, so its
24
+ // files go at the root of the output path.
25
+ //
26
+ // The phase gate mirrors the consumer Root exactly, so `output.path` is not
27
+ // a consumer-target feature: point a language target at another repo and it
28
+ // generates there the same way it would in-tree.
29
+
30
+ import { cmp, each, names } from 'jostraca'
31
+
32
+ import { Project } from 'jostraca'
33
+
34
+ import { KIT } from '@voxgig/apidef'
35
+
36
+ import { Main } from './Main'
37
+ import { Entity } from './Entity'
38
+ import { Feature } from './Feature'
39
+ import { Readme } from './Readme'
40
+ import { Test } from './Test'
41
+ import { AgentGuide } from './AgentGuide'
42
+
43
+
44
+ const ExternalTarget = cmp(function ExternalTarget(props: any) {
45
+ const { model, target, cmpfolder, sdkrelpath } = props
46
+ const ctx$ = props.ctx$
47
+
48
+ ctx$.model = model
49
+
50
+ // Components live in the PROJECT, not in the repo being written to. This
51
+ // pass has retargeted jostraca's output folder, which is what requirePath
52
+ // otherwise resolves against — see utility.resolvePath.
53
+ ctx$.cmpfolder = cmpfolder
54
+
55
+ // The path from the destination back to the SDK project, for a target whose
56
+ // output sits beside the SDK in a known layout.
57
+ ctx$.sdkrelpath = sdkrelpath
58
+
59
+ // The same model preamble the consumer's Root.ts performs before it renders
60
+ // anything: the case-variant name constants (`Name`, `NAME`, ...) and the
61
+ // ProjectName replacement map that every template substitution reads.
62
+ //
63
+ // Done HERE rather than relied upon, because this pass gets the model the
64
+ // in-tree pass never touched — Root mutates the filtered copy it is handed,
65
+ // not this one — and because an SDK project with only out-of-tree targets
66
+ // must generate the same way as one with both.
67
+ model.const = model.const || { name: model.name }
68
+ names(model.const, model.name)
69
+ if (null == model.const.year) {
70
+ model.const.year = new Date().getFullYear()
71
+ }
72
+ names(model, model.name)
73
+
74
+ ctx$.stdrep = ctx$.stdrep || {}
75
+ names(ctx$.stdrep, model.Name, 'Project' + 'Name')
76
+
77
+ const entity = model.main[KIT].entity || {}
78
+ const feature = model.main[KIT].feature || {}
79
+
80
+ // Defaults are inclusive: a phase runs unless the target's model turns it
81
+ // off. Consumer targets (go-cli, go-mcp, py-data, seneca-provider) switch
82
+ // every phase off and emit everything from Main.
83
+ const phase = target.phase || {}
84
+ const phaseActive = (name: string): boolean =>
85
+ false !== (phase[name] && phase[name].active)
86
+
87
+ Project({}, () => {
88
+ names(target, target.name)
89
+
90
+ if (phaseActive('entity')) {
91
+ each(entity, (entity: any) => {
92
+ names(entity, entity.name)
93
+ Entity({ target, entity })
94
+ })
95
+ }
96
+
97
+ if (phaseActive('feature')) {
98
+ each(feature)
99
+ .filter((feature: any) => feature.active)
100
+ .map((feature: any) => {
101
+ names(feature, feature.name)
102
+ Feature({ target, feature })
103
+ })
104
+ }
105
+
106
+ Main({ target })
107
+
108
+ if (phaseActive('readme')) {
109
+ Readme({ target })
110
+ }
111
+
112
+ if (phaseActive('agentguide')) {
113
+ AgentGuide({ target })
114
+ }
115
+
116
+ if (phaseActive('test')) {
117
+ Test({ target })
118
+ }
119
+ })
120
+ })
121
+
122
+
123
+ export {
124
+ ExternalTarget,
125
+ }
@@ -14,6 +14,8 @@
14
14
  // Every value here is derived from the resolved model (model.name, model.origin,
15
15
  // main.kit.info.title) — no new inputs required.
16
16
 
17
+ import { each } from 'jostraca'
18
+
17
19
  import { KIT, nom } from '@voxgig/apidef'
18
20
 
19
21
  const PUBLISHER = 'Voxgig'
@@ -348,6 +350,65 @@ function keywords(model: any): string[] {
348
350
  return ['voxgig', 'sdk', 'generated-sdk', 'openapi', 'api-client', model.name]
349
351
  }
350
352
 
353
+
354
+ // WHO WROTE THE PACKAGE — `main: kit: author` / `main: kit: contributor`.
355
+ //
356
+ // Attribution cannot be derived: it is not a function of the slug, the repo or
357
+ // the API. And because generated output is OVERWRITTEN, a name hand-edited
358
+ // into a manifest is deleted by the next regeneration — silently, because no
359
+ // build step can tell that a person is missing. The seneca-provider target
360
+ // dropped a hand-written provider's author and both its named contributors
361
+ // exactly that way. So attribution is declared in the model and read here.
362
+ //
363
+ // An unset author is the PUBLISHER, which is what every generated SDK manifest
364
+ // has always carried (Package_ts hardcoded it); a project that has never
365
+ // thought about authorship keeps the previous behaviour.
366
+ //
367
+ // PER TARGET, falling back to the model-wide value. One model can produce
368
+ // packages with different authors: the SDK is a generated artefact of the
369
+ // publisher, while a Seneca provider is an independently released package with
370
+ // its own human maintainers. A single model-wide name cannot be right for
371
+ // both — and it was not: the solardemo model named a person, the target that
372
+ // read it credited them, and the SDK's own manifest went on saying Voxgig
373
+ // because it read nothing at all.
374
+ //
375
+ // main: kit: author: { ... } # every package from this model
376
+ // main: kit: target: ts: author: { ... } # ...except this one
377
+ function authorInfo(model: any, target?: string): { name: string, url: string } {
378
+ const perTarget = null == target ? null :
379
+ model?.main?.[KIT]?.target?.[target]?.author
380
+
381
+ const declared = (null != perTarget && '' !== (perTarget.name || '')) ?
382
+ perTarget : (model?.main?.[KIT]?.author || {})
383
+
384
+ const name = null != declared.name && '' !== declared.name ?
385
+ String(declared.name) : PUBLISHER
386
+
387
+ // A declared author with no url gets none — inventing PUBLISHER_URL for a
388
+ // named human would credit them to Voxgig's homepage.
389
+ const url = null != declared.url && '' !== declared.url ? String(declared.url) :
390
+ (PUBLISHER === name ? PUBLISHER_URL : '')
391
+
392
+ return { name, url }
393
+ }
394
+
395
+
396
+ // Contributors, in sorted-key order so the manifest is byte-stable. `each`
397
+ // rather than Object.keys: the model is an aontu map and carries metadata
398
+ // keys alongside its entries.
399
+ //
400
+ // An entry with no name is DROPPED rather than rendered as `{}` — the schema
401
+ // makes `name` required, but a partially-unified model can still reach here
402
+ // during a dry run.
403
+ function contributorList(model: any): { name: string, url: string }[] {
404
+ return each(model?.main?.[KIT]?.contributor || {})
405
+ .filter((c: any) => null != c && null != c.name && '' !== c.name)
406
+ .map((c: any) => ({
407
+ name: String(c.name),
408
+ url: null != c.url && '' !== c.url ? String(c.url) : '',
409
+ }))
410
+ }
411
+
351
412
  // A VALID uppercase env-var token: 'unsolicited-advice' -> 'UNSOLICITED_ADVICE'.
352
413
  //
353
414
  // THE ONLY WAY to build an env-var name segment. There used to be three
@@ -387,6 +448,8 @@ export {
387
448
  pkgDescription,
388
449
  nonAffiliation,
389
450
  keywords,
451
+ authorInfo,
452
+ contributorList,
390
453
  envName,
391
454
  envToken,
392
455
  goModule,