@shd101wyy/yo 0.1.29 → 0.1.30

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 (174) hide show
  1. package/.github/skills/yo-async-effects/SKILL.md +3 -3
  2. package/.github/skills/yo-async-effects/async-effects-recipes.md +19 -11
  3. package/.github/skills/yo-core-patterns/core-patterns-cheatsheet.md +33 -13
  4. package/.github/skills/yo-project-workflow/workflow-cheatsheet.md +1 -1
  5. package/.github/skills/yo-syntax/syntax-cheatsheet.md +59 -21
  6. package/README.md +4 -3
  7. package/out/cjs/index.cjs +771 -676
  8. package/out/cjs/yo-cli.cjs +1003 -898
  9. package/out/cjs/yo-lsp.cjs +834 -739
  10. package/out/esm/index.mjs +716 -621
  11. package/out/types/src/codegen/exprs/async.d.ts +2 -0
  12. package/out/types/src/codegen/exprs/await.d.ts +1 -0
  13. package/out/types/src/codegen/exprs/closures.d.ts +4 -0
  14. package/out/types/src/codegen/functions/context.d.ts +6 -0
  15. package/out/types/src/env.d.ts +2 -0
  16. package/out/types/src/evaluator/builtins/pragma.d.ts +9 -0
  17. package/out/types/src/evaluator/builtins/unsafe.d.ts +8 -0
  18. package/out/types/src/evaluator/context.d.ts +2 -0
  19. package/out/types/src/evaluator/index.d.ts +1 -1
  20. package/out/types/src/evaluator/memory-safety.d.ts +14 -0
  21. package/out/types/src/evaluator/types/flowability.d.ts +6 -0
  22. package/out/types/src/expr-traversal.d.ts +1 -0
  23. package/out/types/src/expr.d.ts +4 -1
  24. package/out/types/src/public-safe-report.d.ts +19 -0
  25. package/out/types/src/tests/comptime-ref-gate.test.d.ts +1 -0
  26. package/out/types/src/tests/pragma-validation.test.d.ts +1 -0
  27. package/out/types/src/tests/public-safe-report.test.d.ts +1 -0
  28. package/out/types/src/tests/type-representation-pointer.test.d.ts +1 -0
  29. package/out/types/src/tests/unsafe-gate.test.d.ts +1 -0
  30. package/out/types/src/tests/unsafe-report-classify.test.d.ts +1 -0
  31. package/out/types/src/types/definitions.d.ts +2 -0
  32. package/out/types/src/types/utils.d.ts +4 -0
  33. package/out/types/src/unsafe-report.d.ts +29 -0
  34. package/out/types/src/value.d.ts +1 -0
  35. package/out/types/tsconfig.tsbuildinfo +1 -1
  36. package/package.json +1 -1
  37. package/scripts/add-pragma-for-pointer-decls.ts +134 -0
  38. package/scripts/add-pragma.ts +58 -0
  39. package/scripts/migrate-amp-method-calls.ts +186 -0
  40. package/scripts/migrate-clone-calls.ts +93 -0
  41. package/scripts/migrate-get-unwrap.ts +166 -0
  42. package/scripts/migrate-index-patterns.ts +210 -0
  43. package/scripts/migrate-index-trait.ts +142 -0
  44. package/scripts/migrate-iterator.ts +150 -0
  45. package/scripts/migrate-self-ptr.ts +220 -0
  46. package/scripts/migrate-skip-pragmas.ts +109 -0
  47. package/scripts/migrate-tostring.ts +134 -0
  48. package/scripts/trim-pragma.ts +130 -0
  49. package/scripts/wrap-extern-calls.ts +161 -0
  50. package/std/alg/hash.yo +3 -2
  51. package/std/allocator.yo +6 -5
  52. package/std/async.yo +2 -2
  53. package/std/collections/array_list.yo +59 -40
  54. package/std/collections/btree_map.yo +19 -18
  55. package/std/collections/deque.yo +9 -8
  56. package/std/collections/hash_map.yo +101 -13
  57. package/std/collections/hash_set.yo +5 -4
  58. package/std/collections/linked_list.yo +39 -4
  59. package/std/collections/ordered_map.yo +3 -3
  60. package/std/collections/priority_queue.yo +14 -13
  61. package/std/crypto/md5.yo +2 -1
  62. package/std/crypto/random.yo +16 -15
  63. package/std/crypto/sha256.yo +2 -1
  64. package/std/encoding/base64.yo +14 -14
  65. package/std/encoding/hex.yo +3 -3
  66. package/std/encoding/json.yo +59 -10
  67. package/std/encoding/punycode.yo +24 -23
  68. package/std/encoding/toml.yo +4 -3
  69. package/std/encoding/utf16.yo +2 -2
  70. package/std/env.yo +43 -28
  71. package/std/error.yo +6 -6
  72. package/std/fmt/display.yo +2 -2
  73. package/std/fmt/index.yo +6 -5
  74. package/std/fmt/to_string.yo +39 -38
  75. package/std/fmt/writer.yo +9 -8
  76. package/std/fs/dir.yo +34 -33
  77. package/std/fs/file.yo +52 -51
  78. package/std/fs/metadata.yo +10 -9
  79. package/std/fs/temp.yo +24 -13
  80. package/std/fs/walker.yo +10 -9
  81. package/std/gc.yo +1 -0
  82. package/std/glob.yo +7 -7
  83. package/std/http/client.yo +15 -14
  84. package/std/http/http.yo +6 -6
  85. package/std/http/index.yo +1 -1
  86. package/std/imm/list.yo +33 -0
  87. package/std/imm/map.yo +2 -1
  88. package/std/imm/set.yo +1 -0
  89. package/std/imm/sorted_map.yo +1 -0
  90. package/std/imm/sorted_set.yo +1 -0
  91. package/std/imm/string.yo +27 -23
  92. package/std/imm/vec.yo +18 -2
  93. package/std/io/reader.yo +2 -1
  94. package/std/io/writer.yo +3 -2
  95. package/std/libc/assert.yo +1 -0
  96. package/std/libc/ctype.yo +1 -0
  97. package/std/libc/dirent.yo +1 -0
  98. package/std/libc/errno.yo +1 -0
  99. package/std/libc/fcntl.yo +1 -0
  100. package/std/libc/float.yo +1 -0
  101. package/std/libc/limits.yo +1 -0
  102. package/std/libc/math.yo +1 -0
  103. package/std/libc/signal.yo +1 -0
  104. package/std/libc/stdatomic.yo +1 -0
  105. package/std/libc/stdint.yo +1 -0
  106. package/std/libc/stdio.yo +1 -0
  107. package/std/libc/stdlib.yo +1 -0
  108. package/std/libc/string.yo +1 -0
  109. package/std/libc/sys/stat.yo +1 -0
  110. package/std/libc/time.yo +1 -0
  111. package/std/libc/unistd.yo +1 -0
  112. package/std/libc/wctype.yo +1 -0
  113. package/std/libc/windows.yo +2 -0
  114. package/std/log.yo +7 -6
  115. package/std/net/addr.yo +5 -4
  116. package/std/net/dns.yo +7 -6
  117. package/std/net/errors.yo +8 -8
  118. package/std/net/tcp.yo +19 -18
  119. package/std/net/udp.yo +13 -12
  120. package/std/os/signal.yo +3 -3
  121. package/std/path.yo +1 -0
  122. package/std/prelude.yo +353 -182
  123. package/std/process/command.yo +40 -23
  124. package/std/process/index.yo +2 -1
  125. package/std/regex/compiler.yo +10 -9
  126. package/std/regex/index.yo +41 -41
  127. package/std/regex/match.yo +2 -2
  128. package/std/regex/parser.yo +21 -21
  129. package/std/regex/vm.yo +42 -41
  130. package/std/string/string.yo +95 -40
  131. package/std/string/string_builder.yo +9 -9
  132. package/std/string/unicode.yo +50 -49
  133. package/std/sync/channel.yo +2 -1
  134. package/std/sync/cond.yo +5 -4
  135. package/std/sync/mutex.yo +4 -3
  136. package/std/sys/advise.yo +1 -0
  137. package/std/sys/bufio/buf_reader.yo +17 -16
  138. package/std/sys/bufio/buf_writer.yo +10 -9
  139. package/std/sys/clock.yo +1 -0
  140. package/std/sys/copy.yo +1 -0
  141. package/std/sys/dir.yo +10 -9
  142. package/std/sys/dns.yo +6 -5
  143. package/std/sys/errors.yo +11 -11
  144. package/std/sys/events.yo +1 -0
  145. package/std/sys/externs.yo +38 -37
  146. package/std/sys/file.yo +17 -16
  147. package/std/sys/future.yo +4 -3
  148. package/std/sys/iov.yo +1 -0
  149. package/std/sys/mmap.yo +1 -0
  150. package/std/sys/path.yo +1 -0
  151. package/std/sys/perm.yo +2 -1
  152. package/std/sys/pipe.yo +1 -0
  153. package/std/sys/process.yo +5 -4
  154. package/std/sys/signal.yo +1 -0
  155. package/std/sys/socketpair.yo +1 -0
  156. package/std/sys/sockinfo.yo +1 -0
  157. package/std/sys/statfs.yo +2 -1
  158. package/std/sys/statx.yo +1 -0
  159. package/std/sys/sysinfo.yo +1 -0
  160. package/std/sys/tcp.yo +15 -14
  161. package/std/sys/temp.yo +1 -0
  162. package/std/sys/time.yo +2 -1
  163. package/std/sys/timer.yo +6 -6
  164. package/std/sys/tty.yo +2 -1
  165. package/std/sys/udp.yo +13 -12
  166. package/std/sys/unix.yo +12 -11
  167. package/std/testing/bench.yo +4 -3
  168. package/std/thread.yo +7 -6
  169. package/std/time/datetime.yo +18 -15
  170. package/std/time/duration.yo +11 -10
  171. package/std/time/instant.yo +4 -4
  172. package/std/time/sleep.yo +1 -0
  173. package/std/url/index.yo +3 -3
  174. package/std/worker.yo +4 -3
@@ -1,6 +1,8 @@
1
1
  import { type FnCallExpr } from "../../expr";
2
+ import type { FutureTraitType } from "../../types/definitions";
2
3
  import type { FunctionGenerationContext } from "../functions/context";
3
4
  export declare function generateAsyncBlock(expr: FnCallExpr, indent: string, context: FunctionGenerationContext): string;
5
+ export declare function findBundleFieldName(futureTraitType: FutureTraitType, stateMachineVariables: Map<string, import("../../evaluator/async/await-analysis-types").CapturedVariable> | undefined, stateMachineFieldAliases?: Map<string, string>): string | undefined;
4
6
  export declare function generateDeferredAsyncBlocks(context: FunctionGenerationContext): void;
5
7
  export declare function preRegisterAsyncBlockTypes(context: FunctionGenerationContext): void;
6
8
  export declare function generateIoAsyncSyncCall(expr: FnCallExpr, indent: string, context: FunctionGenerationContext): string;
@@ -3,3 +3,4 @@ import { type CodeGenContext } from "../utils";
3
3
  export declare function generateAwait(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
4
4
  export declare function generateState(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
5
5
  export declare function generateJoinHandleAwait(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
6
+ export declare function emitIoSpawnEffectInjection(expr: FnCallExpr, futureVar: string, indent: string, context: CodeGenContext): void;
@@ -1,6 +1,10 @@
1
1
  import { type Environment } from "../../env";
2
2
  import { type FnCallExpr } from "../../expr";
3
+ import type { Type } from "../../types/definitions";
4
+ export declare function resolveSomeTypeToConcrete(t: Type): Type;
5
+ import type { FunctionGenerationContext } from "../functions/context";
3
6
  import { type CodeGenContext } from "../utils";
4
7
  export declare function checkVariableIsClosureCaptured(variableName: string, env: Environment, closureCaptureFrameLevel: number): boolean;
5
8
  export declare function isClosureConstruction(expr: FnCallExpr): boolean;
9
+ export declare function registerImplClosureCallMappings(context: FunctionGenerationContext): void;
6
10
  export declare function generateClosureConstruction(expr: FnCallExpr, indent: string, context: CodeGenContext): string;
@@ -51,6 +51,12 @@ export interface FunctionGenerationContext extends CodeGenContext {
51
51
  resultTypeCName: string;
52
52
  captureType: StructType | undefined;
53
53
  analysis: AwaitAnalysisResult;
54
+ closureParamSlots?: {
55
+ fieldName: string;
56
+ cType: string;
57
+ paramName: string;
58
+ paramType: Type;
59
+ }[];
54
60
  }>;
55
61
  asyncCondBranchInfo?: Map<number, {
56
62
  branches: Array<{
@@ -11,6 +11,8 @@ export interface Variable {
11
11
  isOwningTheRcValue: boolean;
12
12
  isOwningTheSameRcValueAs?: Variable;
13
13
  isReassignable?: boolean;
14
+ isRef?: boolean;
15
+ isParameter?: boolean;
14
16
  initializedAtToken: Token | undefined;
15
17
  consumedAtToken: Token | undefined;
16
18
  frameLevel: number;
@@ -0,0 +1,9 @@
1
+ import type { Environment } from "../../env";
2
+ import { type Expr, type FnCallExpr } from "../../expr";
3
+ import type { EvaluatorContext } from "../context";
4
+ export declare function evaluatePragma({ expr, env, context, }: {
5
+ expr: FnCallExpr;
6
+ env: Environment;
7
+ context: EvaluatorContext;
8
+ }): FnCallExpr;
9
+ export declare function preScanForSkipPrelude(program: Expr[], modulePath: string): boolean;
@@ -0,0 +1,8 @@
1
+ import type { Environment } from "../../env";
2
+ import { type FnCallExpr } from "../../expr";
3
+ import type { EvaluatorContext } from "../context";
4
+ export declare function evaluateUnsafe({ expr, env, context, }: {
5
+ expr: FnCallExpr;
6
+ env: Environment;
7
+ context: EvaluatorContext;
8
+ }): FnCallExpr;
@@ -54,6 +54,7 @@ export interface EvaluatorContext {
54
54
  stdPath: string;
55
55
  currentModulePath?: string;
56
56
  isUnsafeFunctionType?: boolean;
57
+ unsafeContext?: boolean;
57
58
  isControlFunctionType?: boolean;
58
59
  enclosingFunctionReturnType?: Type;
59
60
  hasControlFunctionImplicitParams?: boolean;
@@ -65,6 +66,7 @@ export interface EvaluatorContext {
65
66
  token: Token;
66
67
  }>;
67
68
  forceCompileTimeBindings?: boolean;
69
+ deferGenericFnTypeCheckToAssignment?: boolean;
68
70
  isAnalyzingCtfeCapability?: boolean;
69
71
  isInFunctionCallCheckingPhase?: boolean;
70
72
  isInsideIoAsyncCall?: boolean;
@@ -1,6 +1,6 @@
1
1
  import { type Environment } from "../env";
2
2
  import type { Expr } from "../expr";
3
- import { type Token } from "../token";
3
+ import type { Token } from "../token";
4
4
  import type { StructValue } from "../value";
5
5
  import type { LoadModuleFn } from "./context";
6
6
  import { clearAllGlobalImplState, clearGenericImplsFromModule, clearImplsFromModule } from "./values/impl";
@@ -0,0 +1,14 @@
1
+ export type PragmaKind = "AllowUnsafe" | "SkipPrelude" | "SkipWasm" | "SkipWasm32Emscripten" | "SkipWasm32Wasi";
2
+ export declare function registerFilePragma(modulePath: string, kind: PragmaKind): void;
3
+ export declare function fileHasPragma(modulePath: string | undefined, kind: PragmaKind): boolean;
4
+ export declare function _clearPragmaRegistry(): void;
5
+ export declare function _clearPragmaForModule(modulePath: string): void;
6
+ export declare function isImplicitlyUnsafeCapableFile(modulePath: string | undefined): boolean;
7
+ export declare function isAutoGeneratedExpansion(modulePath: string | undefined): boolean;
8
+ type ExternCallSiteRecord = {
9
+ modulePath: string;
10
+ characterOffset: number;
11
+ calleeName: string;
12
+ };
13
+ export declare function recordExternCallSite(record: ExternCallSiteRecord): void;
14
+ export {};
@@ -0,0 +1,6 @@
1
+ import { type Expr } from "../../expr";
2
+ export declare function isFlowableExpr(expr: Expr, options?: {
3
+ allowSameFrameLocal?: boolean;
4
+ allowParameterSource?: boolean;
5
+ allowComptimeSource?: boolean;
6
+ }): boolean;
@@ -1,4 +1,5 @@
1
1
  import { type Expr } from "./expr";
2
+ export declare function allPathsUnwind(expr: Expr): boolean;
2
3
  export declare function evaluatedBodyContainsEscape(expr: Expr): boolean;
3
4
  export declare function exprTreeContainsReturn(expr: Expr): boolean;
4
5
  export declare function exprContainsAwait(expr: Expr): boolean;
@@ -86,6 +86,7 @@ export interface EvaluatedExprData {
86
86
  indexMethodType?: FunctionType;
87
87
  indexMethodValue?: Value;
88
88
  isIndexTraitAddressOf?: boolean;
89
+ isReturnSlot?: boolean;
89
90
  isCompileTimeOnlyAssignment?: boolean;
90
91
  isAnonymousFunctionDefinition?: boolean;
91
92
  comptimeUnrolledBodies?: Expr[];
@@ -190,6 +191,8 @@ export declare const BuiltinFunctions: {
190
191
  typeid: string[];
191
192
  downcast: string[];
192
193
  consume: string[];
194
+ unsafe: string[];
195
+ pragma: string[];
193
196
  macro_expand: string[];
194
197
  as: string[];
195
198
  the: string[];
@@ -609,7 +612,7 @@ export interface ExprToStringConfig {
609
612
  }
610
613
  export declare function exprToString(expr: Expr, config?: ExprToStringConfig): string;
611
614
  export declare function consumeCaseBodyTempVar(evaluatedBody: Expr, env: Environment): Environment;
612
- export declare function attachTempVariableToExpr(expr: Expr, isOwningTheRcValue: boolean, isOwningTheSameRcValueAs?: Variable): void;
615
+ export declare function attachTempVariableToExpr(expr: Expr, isOwningTheRcValue: boolean, isOwningTheSameRcValueAs?: Variable, isRef?: boolean): void;
613
616
  export declare function mergeAndCheckEnvs(env: Environment, bodies: Expr[]): Environment;
614
617
  export declare function replaceFuncCallExprWithFuncCallExpr(funcExpr: FnCallExpr, newFuncExpr: FnCallExpr): void;
615
618
  export declare function replaceFuncCallExprWithAtomExpr(funcExpr: FnCallExpr, newAtomExpr: AtomExpr): void;
@@ -0,0 +1,19 @@
1
+ export interface PublicSafeFinding {
2
+ file: string;
3
+ line: number;
4
+ column: number;
5
+ declName: string;
6
+ slot: "parameter" | "return";
7
+ pointerType: string;
8
+ snippet: string;
9
+ }
10
+ export interface PublicSafeReport {
11
+ findings: PublicSafeFinding[];
12
+ totals: {
13
+ filesScanned: number;
14
+ publicDeclsScanned: number;
15
+ findings: number;
16
+ };
17
+ }
18
+ export declare function generatePublicSafeReport(rootPath: string): PublicSafeReport;
19
+ export declare function formatPublicSafeReport(report: PublicSafeReport): string;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -113,6 +113,7 @@ export interface FunctionParameter {
113
113
  isCompileTimeOnly: boolean;
114
114
  isQuote: boolean;
115
115
  isOwningTheRcValue: boolean;
116
+ isRef?: boolean;
116
117
  exprs: FunctionParameterExprs;
117
118
  assignedValue?: Value;
118
119
  }
@@ -213,6 +214,7 @@ export interface FunctionReturn {
213
214
  isCompileTimeOnly: boolean;
214
215
  isUnquote: boolean;
215
216
  label: string;
217
+ isRef?: boolean;
216
218
  }
217
219
  export interface FunctionType extends Type {
218
220
  tag: TypeTag.Function;
@@ -8,7 +8,11 @@ export declare function isComptimeOnlyType(type: Type, env: Environment): boolea
8
8
  export declare function isRuntimeOnlyType(type: Type, env: Environment): boolean;
9
9
  export declare function typeContainsRcType(type?: Type, checkedTypes?: Type[]): boolean;
10
10
  export declare function typeIsControlBound(type?: Type, checkedTypes?: Type[]): boolean;
11
+ export declare function typeRepresentationContainsRawPtr(type?: Type, checkedTypes?: Type[]): boolean;
12
+ export declare function typeMayProvideSliceSource(type?: Type, checkedTypes?: Type[]): boolean;
11
13
  export declare function typeContainsSomeType(type?: Type, checkedTypes?: Type[]): boolean;
14
+ export declare function typeContainsUnboundSomeType(type?: Type, boundNames?: Set<string>, checkedTypes?: Type[]): boolean;
15
+ export declare function typeContainsSomeTypeForCodegenParam(type?: Type, checkedTypes?: Type[]): boolean;
12
16
  export declare function typeContainsUnknownValue(type: Type, visited?: Set<string>): boolean;
13
17
  export declare function getAllSomeTypes(type: Type): Set<SomeType>;
14
18
  export declare function typeRequiresInference(type?: Type): boolean;
@@ -0,0 +1,29 @@
1
+ export type UnsafeSubKind = "extern-call" | "deref" | "arith" | "addr-of" | "other";
2
+ export interface UnsafeFinding {
3
+ file: string;
4
+ line: number;
5
+ column: number;
6
+ kind: "unsafe" | "asm" | "extern" | "pragma";
7
+ subKind?: UnsafeSubKind;
8
+ calleeName?: string;
9
+ snippet: string;
10
+ safetyComment?: string;
11
+ }
12
+ export interface UnsafeReport {
13
+ privilegedFiles: string[];
14
+ findings: UnsafeFinding[];
15
+ totals: {
16
+ filesScanned: number;
17
+ privileged: number;
18
+ unsafeSites: number;
19
+ unsafeBySubKind: Record<UnsafeSubKind, number>;
20
+ asmSites: number;
21
+ externSites: number;
22
+ };
23
+ topExternCallees: Array<{
24
+ callee: string;
25
+ count: number;
26
+ }>;
27
+ }
28
+ export declare function generateUnsafeReport(rootPath: string): UnsafeReport;
29
+ export declare function formatUnsafeReport(report: UnsafeReport): string;
@@ -71,6 +71,7 @@ export type UnknownValue = {
71
71
  type: Type;
72
72
  variableName?: string;
73
73
  isRuntimeOnly?: boolean;
74
+ resolvedFuncValueId?: string;
74
75
  };
75
76
  export type PtrValue = {
76
77
  tag: ValueTag.Ptr;