@venizia/vulcan 0.4.9 → 0.4.10-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,5 @@
1
1
  import { HookConstants } from './common/index.ts';
2
+ import { HostPatterns } from './host-pattern.ts';
2
3
  import type { IWriteHit } from './common/index.ts';
3
4
  import { CommandView } from './command-view.ts';
4
5
  import { HookDecision } from './decision.ts';
@@ -18,10 +19,19 @@ interface IRemoteHostsPolicy {
18
19
  trusted: string[];
19
20
  /** Hosts that only the strict read-only forms may reach. */
20
21
  readOnly: string[];
21
- /** Where the personal trusted list lives, for the message. */
22
+ /** Where the personal list lives, for the message. */
22
23
  localFile?: string;
23
24
  }
24
25
 
26
+ /** What the personal list holds: trusted hosts, read-only hosts, and the numbers of the lines that were skipped. */
27
+ interface IPersonalHosts {
28
+ trusted: string[];
29
+ readOnly: string[];
30
+ skipped: number[];
31
+ }
32
+
33
+ const READONLY_PREFIX = 'readonly:';
34
+
25
35
  interface ISegment {
26
36
  words: string[];
27
37
  /** `$(...)` or a backtick ran inside it: what it reaches is decided at run time. */
@@ -880,12 +890,34 @@ export class RemoteHosts {
880
890
  });
881
891
  }
882
892
 
883
- /** The personal trusted list: one host per line, `#` starts a comment. */
884
- static parseTrustedList(opts: { text: string }): string[] {
885
- return opts.text
886
- .split('\n')
887
- .map((line) => line.replace(/#.*$/, '').trim())
888
- .filter((line) => line !== '');
893
+ /**
894
+ * The personal list: one host per line, `#` starts a comment, `readonly: <host>` is a read-only host. An entry
895
+ * that is not a host name or a `*` pattern (a lone `*`, a user, a port, a path) is skipped, never trusted, and its
896
+ * line number is returned in `skipped`.
897
+ */
898
+ static parsePersonalList(opts: { text: string }): IPersonalHosts {
899
+ const personal: IPersonalHosts = { trusted: [], readOnly: [], skipped: [] };
900
+
901
+ opts.text.split('\n').forEach((raw, index) => {
902
+ const line = raw.replace(/#.*$/, '').trim();
903
+
904
+ if (line === '') {
905
+ return;
906
+ }
907
+
908
+ const isReadOnly = line.startsWith(READONLY_PREFIX);
909
+ const value = isReadOnly ? line.slice(READONLY_PREFIX.length).trim() : line;
910
+
911
+ if (!HostPatterns.isValid({ value })) {
912
+ personal.skipped.push(index + 1);
913
+
914
+ return;
915
+ }
916
+
917
+ (isReadOnly ? personal.readOnly : personal.trusted).push(value);
918
+ });
919
+
920
+ return personal;
889
921
  }
890
922
 
891
923
  /** Why each host this command reaches may not be reached without asking; empty means nothing to ask. */
package/src/router.ts CHANGED
@@ -106,6 +106,10 @@ const ACCEPTED_ARGS: Record<string, IAcceptedArgs> = {
106
106
  EventFlags.FLOW,
107
107
  EventFlags.REF,
108
108
  EventFlags.STATUS,
109
+ EventFlags.TITLE,
110
+ EventFlags.WHY,
111
+ EventFlags.CONTEXT,
112
+ EventFlags.NEXT,
109
113
  EventFlags.ACTOR,
110
114
  EventFlags.DIR,
111
115
  EventFlags.SINCE,