@astrosheep/square 0.3.12 → 0.3.13

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 (121) hide show
  1. package/codex-plugin/.codex-plugin/plugin.json +1 -1
  2. package/codex-plugin/hooks/hooks.json +9 -0
  3. package/dist/activity-feed.d.ts +14 -0
  4. package/dist/activity-feed.js +5 -5
  5. package/dist/activity.d.ts +9 -0
  6. package/dist/activity.js +111 -90
  7. package/dist/artifact.d.ts +20 -0
  8. package/dist/artifact.js +10 -29
  9. package/dist/automatic-session.d.ts +5 -0
  10. package/dist/automatic-session.js +86 -0
  11. package/dist/boundary-presentation.d.ts +5 -0
  12. package/dist/boundary-presentation.js +5 -4
  13. package/dist/claude-hook.d.ts +9 -0
  14. package/dist/claude-hook.js +35 -3
  15. package/dist/cli/context.d.ts +35 -0
  16. package/dist/cli/context.js +25 -30
  17. package/dist/cli/harness-command.d.ts +28 -0
  18. package/dist/cli/harness-command.js +29 -14
  19. package/dist/cli/maintenance-commands.d.ts +7 -0
  20. package/dist/cli/maintenance-commands.js +3 -3
  21. package/dist/cli/meta-commands.d.ts +5 -0
  22. package/dist/cli/observation-commands.d.ts +20 -0
  23. package/dist/cli/observation-commands.js +155 -128
  24. package/dist/cli/program.d.ts +2 -0
  25. package/dist/cli/program.js +2 -12
  26. package/dist/cli/registry.d.ts +9 -0
  27. package/dist/cli/registry.js +1 -2
  28. package/dist/cli/square-commands.d.ts +34 -0
  29. package/dist/cli/square-commands.js +81 -74
  30. package/dist/cmd/notify-once.d.ts +2 -0
  31. package/dist/codex-hook.d.ts +10 -0
  32. package/dist/codex-hook.js +35 -3
  33. package/dist/decisions.d.ts +92 -0
  34. package/dist/decisions.js +83 -77
  35. package/dist/delivery-health.d.ts +21 -0
  36. package/dist/delivery-health.js +40 -34
  37. package/dist/delivery.d.ts +81 -0
  38. package/dist/delivery.js +60 -22
  39. package/dist/file-lock.d.ts +6 -0
  40. package/dist/harness-claude.d.ts +19 -0
  41. package/dist/harness-claude.js +8 -3
  42. package/dist/harness-codex.d.ts +29 -0
  43. package/dist/harness-codex.js +2 -2
  44. package/dist/harness-links.d.ts +17 -0
  45. package/dist/harness-links.js +2 -2
  46. package/dist/harness-pi.d.ts +11 -0
  47. package/dist/harness-pi.js +2 -2
  48. package/dist/harness-stage.d.ts +6 -0
  49. package/dist/harness.d.ts +20 -0
  50. package/dist/harness.js +5 -3
  51. package/dist/help.d.ts +6 -0
  52. package/dist/help.js +6 -5
  53. package/dist/identity.d.ts +13 -0
  54. package/dist/inbox.d.ts +2 -0
  55. package/dist/inbox.js +15 -19
  56. package/dist/index.d.ts +13 -0
  57. package/dist/index.js +31 -69
  58. package/dist/landing.d.ts +10 -0
  59. package/dist/landing.js +95 -0
  60. package/dist/list.d.ts +1 -0
  61. package/dist/list.js +40 -18
  62. package/dist/model.d.ts +147 -0
  63. package/dist/model.js +12 -2
  64. package/dist/notifications.d.ts +30 -0
  65. package/dist/notifications.js +75 -91
  66. package/dist/open-square.d.ts +11 -0
  67. package/dist/open-square.js +4 -0
  68. package/dist/participant-identity.d.ts +1 -0
  69. package/dist/participant-identity.js +3 -0
  70. package/dist/paseo-connection.d.ts +15 -0
  71. package/dist/paseo-delivery.d.ts +14 -0
  72. package/dist/paseo-state.d.ts +11 -0
  73. package/dist/paseo-timeline.d.ts +16 -0
  74. package/dist/presence.d.ts +3 -0
  75. package/dist/presence.js +42 -0
  76. package/dist/presentation.d.ts +91 -0
  77. package/dist/presentation.js +33 -29
  78. package/dist/presented.d.ts +11 -0
  79. package/dist/registry.d.ts +58 -0
  80. package/dist/registry.js +36 -3
  81. package/dist/routes.d.ts +42 -0
  82. package/dist/runtime.d.ts +45 -0
  83. package/dist/runtime.js +42 -34
  84. package/dist/search.d.ts +11 -0
  85. package/dist/square-core.d.ts +111 -0
  86. package/dist/square-core.js +7 -0
  87. package/dist/square-facade.d.ts +86 -0
  88. package/dist/square-facade.js +1 -0
  89. package/dist/square-file-adapter.d.ts +18 -0
  90. package/dist/square-file-adapter.js +70 -0
  91. package/dist/square-storage.d.ts +20 -0
  92. package/dist/square-storage.js +171 -0
  93. package/dist/square-wiring.d.ts +19 -0
  94. package/dist/square-wiring.js +70 -0
  95. package/dist/square.d.ts +2 -0
  96. package/dist/state-cell.d.ts +14 -0
  97. package/dist/state-cell.js +1 -0
  98. package/dist/stream.d.ts +3 -0
  99. package/dist/stream.js +19 -23
  100. package/dist/time.d.ts +6 -0
  101. package/dist/views.d.ts +95 -0
  102. package/dist/views.js +81 -0
  103. package/dist/wake-attempts.d.ts +39 -0
  104. package/dist/wake-evidence.d.ts +12 -0
  105. package/dist/wake-evidence.js +7 -10
  106. package/dist/wake-port.d.ts +20 -0
  107. package/dist/wake-sink.d.ts +12 -0
  108. package/dist/wakes.d.ts +40 -0
  109. package/dist/wakes.js +62 -0
  110. package/dist/watch.d.ts +2 -0
  111. package/dist/watch.js +89 -210
  112. package/extensions/square-opencode.js +27 -1
  113. package/extensions/square-pi.js +13 -0
  114. package/package.json +5 -2
  115. package/skills/brainstorm/SKILL.md +26 -26
  116. package/skills/square/.claude-plugin/plugin.json +1 -1
  117. package/skills/square/SKILL.md +47 -29
  118. package/skills/square/hooks/hooks.json +9 -0
  119. package/skills/square-feedback/SKILL.md +2 -2
  120. package/dist/compact.js +0 -26
  121. package/dist/square-application.js +0 -193
@@ -0,0 +1,35 @@
1
+ import { type HardCap } from '../model.js';
2
+ export declare const DEFAULT_SQUARE_PATH = ".square/SQUARE.square";
3
+ export interface CommandContext {
4
+ squarePath: string;
5
+ name?: string;
6
+ homeDir: string;
7
+ command: string;
8
+ }
9
+ export interface CommandSpec<Intent = unknown, Result = void> {
10
+ parse(argv: string[], context: CommandContext): Intent;
11
+ execute(intent: Intent, context: CommandContext): Promise<Result> | Result;
12
+ present(result: Result, context: CommandContext): void;
13
+ }
14
+ export declare function readStdinSync(): string;
15
+ export declare function resolveBody(arg: string): string;
16
+ export declare function readPipedBodyFallback(): string | undefined;
17
+ export declare function fail(message: string, exitCode?: number): never;
18
+ export declare function usage(command: string): never;
19
+ export declare function requireValue(args: string[], index: number, flag: string): string;
20
+ export declare function parseDurationMs(value: string, flag: string): number;
21
+ export declare function parsePositiveInteger(value: string, flag: string): number;
22
+ export declare function parseNonNegativeInteger(value: string, flag: string): number;
23
+ export declare function parseHardCap(value: string): HardCap;
24
+ export declare function parseNameList(value: string, flag: string): string[];
25
+ export declare function requireParticipant(name: string | undefined): string;
26
+ export interface ParsedGlobalArgs {
27
+ squarePath: string;
28
+ explicitSquarePath: boolean;
29
+ multipleSquares: boolean;
30
+ name?: string;
31
+ args: string[];
32
+ }
33
+ export declare function parseGlobalArgs(rawArgs: string[]): ParsedGlobalArgs;
34
+ export declare function locationIsRequired(command: string): boolean;
35
+ export declare function defaultContext(command: string, squarePath: string, name?: string): CommandContext;
@@ -1,9 +1,8 @@
1
1
  import fs from 'node:fs';
2
2
  import os from 'node:os';
3
- import path from 'node:path';
4
- import { loadSquare } from '../artifact.js';
5
3
  import { commandUsageHint } from '../help.js';
6
4
  import { parseParticipantList, validateName } from '../model.js';
5
+ import { localParticipantName } from '../registry.js';
7
6
  export const DEFAULT_SQUARE_PATH = '.square/SQUARE.square';
8
7
  export function readStdinSync() {
9
8
  try {
@@ -88,30 +87,17 @@ export function requireParticipant(name) {
88
87
  validateName(name);
89
88
  return name;
90
89
  }
91
- function resolveDefaultSquarePath() {
92
- const directory = path.join(process.cwd(), '.square');
93
- let entries;
94
- try {
95
- entries = fs.readdirSync(directory, { withFileTypes: true });
96
- }
97
- catch {
98
- return { path: DEFAULT_SQUARE_PATH, multiple: false };
99
- }
100
- const candidates = [];
101
- for (const entry of entries) {
102
- if (!entry.isFile() || !entry.name.endsWith('.square'))
103
- continue;
104
- const fullPath = path.join(directory, entry.name);
105
- try {
106
- const doc = loadSquare(fullPath);
107
- candidates.push({ relPath: path.relative(process.cwd(), fullPath), at: doc.acts.at(-1)?.at ?? fs.statSync(fullPath).mtimeMs });
108
- }
109
- catch {
110
- // Unreadable artifacts are not implicit command targets.
111
- }
112
- }
113
- candidates.sort((a, b) => b.at - a.at);
114
- return { path: candidates[0]?.relPath ?? DEFAULT_SQUARE_PATH, multiple: candidates.length > 1 };
90
+ const LOCATION_REQUIRED_COMMANDS = new Set(['join', 'catch', 'express', 'done', 'hold', 'resume']);
91
+ function configuredLocation() {
92
+ const value = process.env.SQUARE_LOCATION?.trim();
93
+ return value === '' ? undefined : value;
94
+ }
95
+ function configuredName() {
96
+ const value = process.env.SQUARE_PARTICIPANT_NAME?.trim();
97
+ if (!value)
98
+ return undefined;
99
+ validateName(value);
100
+ return value;
115
101
  }
116
102
  export function parseGlobalArgs(rawArgs) {
117
103
  const args = [...rawArgs];
@@ -129,14 +115,23 @@ export function parseGlobalArgs(rawArgs) {
129
115
  index -= 1;
130
116
  }
131
117
  }
118
+ if (name === undefined)
119
+ name = configuredName();
132
120
  if (name !== undefined)
133
121
  validateName(name);
134
122
  const explicitSquarePath = requestedPath !== undefined;
135
123
  const command = args[0];
136
- const resolved = !explicitSquarePath && !['ls', 'list', 'version', 'install', 'uninstall'].includes(command ?? '')
137
- ? resolveDefaultSquarePath()
138
- : { path: requestedPath ?? DEFAULT_SQUARE_PATH, multiple: false };
139
- return { squarePath: resolved.path, explicitSquarePath, multipleSquares: resolved.multiple, name, args };
124
+ const configured = configuredLocation();
125
+ if (command !== undefined && !['--help', '-h'].includes(command) && locationIsRequired(command) && requestedPath === undefined && configured === undefined) {
126
+ fail(`✕ ${command} needs a square location\n» square ls`);
127
+ }
128
+ const squarePath = requestedPath ?? configured ?? DEFAULT_SQUARE_PATH;
129
+ if (name === undefined && command !== undefined && locationIsRequired(command))
130
+ name = localParticipantName(squarePath);
131
+ return { squarePath, explicitSquarePath: explicitSquarePath || configured !== undefined, multipleSquares: false, name, args };
132
+ }
133
+ export function locationIsRequired(command) {
134
+ return LOCATION_REQUIRED_COMMANDS.has(command);
140
135
  }
141
136
  export function defaultContext(command, squarePath, name) {
142
137
  return { command, squarePath, name, homeDir: os.homedir() };
@@ -0,0 +1,28 @@
1
+ import { executeHarnessTarget, type HarnessAction } from '../harness.js';
2
+ import { type CommandSpec } from './context.js';
3
+ export type HarnessCommandAction = HarnessAction;
4
+ export interface ParsedHarnessCommand {
5
+ target?: string;
6
+ }
7
+ export interface ParsedInstallCommand {
8
+ targets: string[];
9
+ all: boolean;
10
+ force: boolean;
11
+ }
12
+ export interface HarnessCommandResult {
13
+ lines: string[];
14
+ notes: string[];
15
+ failures: string[];
16
+ }
17
+ type HarnessTargetExecutor = typeof executeHarnessTarget;
18
+ export declare function executeTargetBatch(targets: string[], action: 'install' | 'uninstall', context: {
19
+ homeDir: string;
20
+ squarePath?: string;
21
+ force: boolean;
22
+ }, executeTarget?: HarnessTargetExecutor): Promise<HarnessCommandResult>;
23
+ export declare const installCommand: CommandSpec<ParsedInstallCommand, HarnessCommandResult>;
24
+ export declare const uninstallCommand: CommandSpec<ParsedInstallCommand, HarnessCommandResult>;
25
+ export declare const harnessCommand: CommandSpec<ParsedHarnessCommand, HarnessCommandResult>;
26
+ export declare function formatHarnessResult(result: HarnessCommandResult): string;
27
+ export declare function runHarnessCommand(argv: string[], squarePath?: string): Promise<string>;
28
+ export {};
@@ -26,24 +26,38 @@ function parseInstall(argv, action) {
26
26
  throw new Error(`Cannot combine ${action} --all with named targets`);
27
27
  return { targets, all, force };
28
28
  }
29
+ export async function executeTargetBatch(targets, action, context, executeTarget = executeHarnessTarget) {
30
+ const results = [];
31
+ const failures = [];
32
+ for (const target of targets) {
33
+ try {
34
+ results.push(await executeTarget(target, action, context));
35
+ }
36
+ catch (error) {
37
+ failures.push(`✕ ${target} ${action} failed: ${error instanceof Error ? error.message : String(error)}`);
38
+ }
39
+ }
40
+ return {
41
+ notes: results.flatMap((result) => result.notes),
42
+ lines: results.flatMap((result) => result.lines),
43
+ failures,
44
+ };
45
+ }
29
46
  function targetCommand(action) {
30
47
  return {
31
48
  parse(argv) { return parseInstall(argv, action); },
32
49
  async execute(intent, context) {
33
- const results = [];
34
- for (const target of installTargets(intent, action)) {
35
- results.push(await executeHarnessTarget(target, action, {
36
- homeDir: context.homeDir,
37
- squarePath: context.squarePath,
38
- force: intent.force,
39
- }));
40
- }
41
- return {
42
- notes: results.flatMap((result) => result.notes),
43
- lines: results.flatMap((result) => result.lines),
44
- };
50
+ return executeTargetBatch(installTargets(intent, action), action, {
51
+ homeDir: context.homeDir,
52
+ squarePath: context.squarePath,
53
+ force: intent.force,
54
+ });
55
+ },
56
+ present(result) {
57
+ process.stdout.write(formatHarnessResult(result));
58
+ if (result.failures.length > 0)
59
+ process.exitCode = 1;
45
60
  },
46
- present(result) { process.stdout.write(formatHarnessResult(result)); },
47
61
  };
48
62
  }
49
63
  export const installCommand = targetCommand('install');
@@ -77,6 +91,7 @@ export const harnessCommand = {
77
91
  return {
78
92
  notes: results.flatMap((result) => result.notes),
79
93
  lines: results.flatMap((result) => result.lines),
94
+ failures: [],
80
95
  };
81
96
  },
82
97
  present(result) {
@@ -84,7 +99,7 @@ export const harnessCommand = {
84
99
  },
85
100
  };
86
101
  export function formatHarnessResult(result) {
87
- return `${[...result.notes, ...result.lines].join('\n')}\n`;
102
+ return `${[...result.notes, ...result.lines, ...result.failures].join('\n')}\n`;
88
103
  }
89
104
  export function runHarnessCommand(argv, squarePath) {
90
105
  const context = { homeDir: os.homedir(), squarePath: squarePath ?? '.square/SQUARE.square', command: 'harness' };
@@ -0,0 +1,7 @@
1
+ import { type CommandSpec } from './context.js';
2
+ interface DoctorResult {
3
+ output: string;
4
+ exitCode?: number;
5
+ }
6
+ export declare const doctorCommand: CommandSpec<undefined, DoctorResult>;
7
+ export {};
@@ -1,4 +1,4 @@
1
- import { diagnoseSquareFile } from '../artifact.js';
1
+ import { diagnoseSquareFile } from '../square-storage.js';
2
2
  import { renderDoctorClean, renderDoctorUnfixable, withPathOutput } from '../presentation.js';
3
3
  import { inSquareCount } from '../runtime.js';
4
4
  import { usage } from './context.js';
@@ -10,7 +10,7 @@ export const doctorCommand = {
10
10
  },
11
11
  execute(_intent, context) {
12
12
  const diagnosis = diagnoseSquareFile(context.squarePath);
13
- if (diagnosis.unfixable !== undefined || diagnosis.doc === undefined) {
13
+ if (diagnosis.unfixable !== undefined || diagnosis.state === undefined) {
14
14
  return {
15
15
  output: withPathOutput(context.squarePath, renderDoctorUnfixable(diagnosis.unfixable ?? 'the snapshot could not be decoded')),
16
16
  exitCode: 2,
@@ -18,7 +18,7 @@ export const doctorCommand = {
18
18
  }
19
19
  return {
20
20
  output: withPathOutput(context.squarePath, renderDoctorClean(), {
21
- participantCount: inSquareCount(diagnosis.doc),
21
+ participantCount: inSquareCount(diagnosis.state),
22
22
  }),
23
23
  };
24
24
  },
@@ -0,0 +1,5 @@
1
+ import { type CommandSpec } from './context.js';
2
+ export declare const helpCommand: CommandSpec<{
3
+ command?: string;
4
+ }, string>;
5
+ export declare const versionCommand: CommandSpec<undefined, string>;
@@ -0,0 +1,20 @@
1
+ import { type ActivitiesOptions, type WatchOptions } from '../model.js';
2
+ import { type CommandSpec } from './context.js';
3
+ export declare const listCommand: CommandSpec<string[]>;
4
+ interface StreamIntent {
5
+ ndjson: boolean;
6
+ forName?: string;
7
+ }
8
+ export declare const streamCommand: CommandSpec<StreamIntent>;
9
+ export declare const catchCommand: CommandSpec<WatchOptions>;
10
+ export declare const historyCommand: CommandSpec<ActivitiesOptions, string>;
11
+ export declare const participantsCommand: CommandSpec<undefined, string>;
12
+ export declare const statusCommand: CommandSpec<undefined, string>;
13
+ interface InboxIntent {
14
+ sessionId: string;
15
+ json: boolean;
16
+ }
17
+ export declare const inboxCommand: CommandSpec<InboxIntent, string>;
18
+ export declare const claudeHookCommand: CommandSpec<undefined, string>;
19
+ export declare const codexHookCommand: CommandSpec<undefined, string>;
20
+ export {};